Questions tagged [python-3.x]

DO NOT UTILIZE UNLESS YOUR INQUIRY IS FOR SOLELY PYTHON 3 PURPOSES. Please ensure to consistently employ this in tandem with the customary [python] label.

"I'm trying to figure out the best way to use Selenium and Python to send a character sequence to a contenteditable element that has its attribute set

Recently, I've been experimenting with using Python 3.6 and Selenium to automate a simple task - logging into a chat website and sending messages automatically. is the webpage where I want to send the messages. Despite my limited experience with Python, ...

Repairing the scientific notation in a JSON file to convert it to a floating

I'm currently facing a challenge with converting the output format of certain keys in a JSON file from scientific notation to float values within the JSON dictionary. For instance, I want to change this: {'message': '', 'result': [{'Ask': 8.982e-05 ...

Parsing a specific row of a CSV file in Python

My CSV file contains millions of rows, and I need to start iterating from the 10,000,000th row. Currently, I am using the following code: with open(csv_file, encoding='UTF-8') as f: r = csv.reader(f) for row_number, row in enumerate(r ...

Steps for importing the mongo variable from the app that is bound to the application

I have two files, app.py and views.py app.py from flask import Flask from flask_pymongo import PyMongo app = Flask(__name__) app.config["MONGO_URI"] = "mongodb://local:27017/local" mongo = PyMongo(app) from views import profileview profileview.register(ap ...

Encountering issues with the functionality of the Pyinstaller executable file

After creating an executable using pyinstaller, I faced an issue where the executable file would open a blank cmd window that closes after a few seconds. Interestingly, when I run the python file directly using python file.py in the command prompt, it work ...

Implementing Conditional Statements in Date-picker with Selenium WebDriver using Python

As a newcomer to Python/Selenium, I am attempting to construct a statement that will execute an alternative action when the specified element cannot be located. Below is the code snippet in question. pickActiveDay = driver.find_element_by_xpath('//di ...

Steps for reusing a selenium browser sessionIs it possible to reuse

I'm facing an issue while trying to access a pre-existing selenium browser session from a separate python process. The reuse logic works perfectly within the same python script, but fails when separated into a different script, displaying the following err ...

Gather information from a table using pagination features

Attempting to extract data from a paginated table using Selenium. The website being scraped does not have pagination in the URL. table = '//*[@id="result-tables"]/div[2]/div[2]/div/table/tbody' home = driver.find_elements(By.XPATH, '//tbody/tr/t ...

I'm looking for the location of WidgetRedirector within Python3. Where should I start searching

I initially had success using a tkform library in Python2, which worked flawlessly. However, upon transitioning to Python3, I encountered issues running it, specifically with the line: from idlelib.WidgetRedirector import WidgetRedirector It appears that ...

Python3 Selenium - Issue encountered while retrieving the text value from an element on an HTML webpage (web scraping)

On a website, I am working with the HTML code below to extract the number of jobs from a table: <span class="k-pager-info k-label">1 - 10 of 16 items</span> Although I can locate the element successfully through different methods, wh ...

Appending the elements of a list after importing them from a file in Python

My goal is to read elements from a file, add each line to print its output. However, I have been unsuccessful in my attempts so far. For example, if I try to access a certain number: with open('test.txt', 'r') as f: for line in f: ...

Python script to extract product information from Walmart search results

Attempting to gather search results from Walmart has been a challenge for me. For instance, let's navigate to the website "" Then, try to extract only the text from the element identified by the class name search-product-result, using python. ...

An error has been identified in the script while attempting to extract names and addresses from the generated results

I have developed a script to extract the names and addresses of various results (56 in this scenario) from a website. The addresses are only visible once a click is triggered on each result. However, when executing the script, I am able to obtain two resul ...

Exploring the Use of Named Pipes or Shared Memory Files in Python

Can named pipes in Python be utilized for a specific use case? I am trying to achieve the following using named pipes. fn = path/to/my/file.ext os.mkfifo(fn) subprocess.check_output(args=(bar -o fn).split()) foo(fn) I want to avoid writing the output of s ...

Simultaneous parsing of files using several CPU cores

Earlier, I posed a question that was related but more general (check out this response). Now, my question is very specific. The only code that matters to me is: result = {} for line in open('input.txt'): key, value = parse(line) result[key] = value ...

Can anyone tell me why the file content disappears whenever I try to save my modifications in Python?

In my file test_final.txt, I have a collection of simple words and sentences that I want to shuffle using the shuffle method. However, when I implement the code, it empties out my test_final.txt. Additionally, I am struggling to understand why the Shuffle ...

Converting bytes into encoded strings in Python 3

Presently, my Python 2.7 code is set up to handle <str> objects received over a socket connection. Throughout the codebase, we heavily rely on <str> objects for various operations and comparisons. Transitioning to Python 3 has revealed that soc ...

What strategies can be used to create a Page Object Model that is free from redundancy?

Currently, I am working on automating UI testing using the Page Object Model (POM) in Python with Selenium. One question that I have is how to handle duplicate test cases efficiently. For instance, let's consider two web pages: the Login page and the ...

Delaying between typed characters in Selenium SendKeys can be achieved by implementing a small pause

I have encountered an issue while using an actions chain to input text, where duplicate characters appear. I suspect this might be due to the lack of delay. How can I fix this problem? Here is an example code snippet: big_text = "Lorem ipsum dolor sit ...

What is the best method for incrementally transferring significant volumes of data to memory?

Currently, I am engaged in processing signals on an extensive dataset of images. This involves converting the images into large feature vectors that follow a specific structure (number_of_transforms, width, height, depth). Due to the size of these feature ...

Discover the method to obtain a decoded string containing the character "" using the base64 module

Struggling to correctly format the path using the base64 module, my desired output should resemble: C:UsersUser_NameDocumentsphotosphoto.png In a previous attempt, I checked the variable image_open and saw the slashes. However, after decoding and ...

Minimizing data entries in a Pandas DataFrame based on index

When working with multiple datafiles, I use the following code to load them: df = pd.concat((pd.read_csv(f[:-4]+'.txt', delimiter='\s+', header=8) for f in files)) The resulting DataFrame looks like this: ...

Retrieve a section of a JSON file in Python and save it into a new JSON file

I need to filter out specific data from a JSON file using a predefined list of keys and save it as a new JSON file. For example: { "211": { "year": "2020", "field": "chemistry" }, " ...

Tips for inputting a phone number into a form using Python

Can someone help with automating the completion of the application form below using Python? enter image description here I am struggling to fill out the phone number field in the form. The last name, first name, and email are randomly populated from the ...

Using selenium to overcome access restrictions

While trying to automate website navigation using Selenium, encountering an issue stating: Access Denied. The server denies permission to access "http://tokopedia.com/". from selenium import webdriver from selenium.common.exceptions import NoSuch ...

Is it two never-ending cycles taking turns?

Seeking a solution to this particular issue: There are two functions that need to be implemented: def function1(): while True: print("x") def function2(): while True: print("y") The goal is to execute these functions alternately ...

What are the steps to start running the while loop?

To provide more clarity: I am developing an intersection control system for cars where each car must register its address in a shared list (intersectionList) if it intends to cross the intersection. If cars are on road piece 20 or 23, they add their addre ...

pytrends_json.decoder.JSONDecodeError: Anticipating a value at line 1, column 1 (character 0)

When I execute this code, I encounter an error: from pytrends.request import TrendReq google_username = '' google_password = '' pytrend = TrendReq(google_username, google_password, custom_useragent='My Pytrends Script') pytrend.build_payload(kw_list=['app ...

Recreate the index functionality using a generator

The Python 3 filter function is useful for returning elements from an Iterable that meet specific criteria set by a filter function. What if instead of getting the elements, I want to obtain the index of those elements? It's similar to using the index meth ...

Unable to establish a connection with the python3 service located at /usr/local/bin/geckodriver

Here is the code snippet I am using: #!/usr/bin/python3 from selenium import webdriver driver = webdriver.Firefox(executable_path=r'/usr/local/bin/geckodriver') driver.get('http://www.python.org') The error that I am encountering is ...

I am eager to investigate why this method suddenly stops looping after processing the second record

I need to create a button that loops through all records and performs a method that generates a list of ranges between two fields. Then, it should remove another record from the list and place the value in the result field. I have implemented the code bel ...

The Wikipedia application programming interface (API) was unable to locate a particular web page (URL containing an apostrophe)

While I am able to retrieve pageviews info for other pages, I'm encountering an error when trying to fetch data from a particular page. The error message reads: File "<unknown>", line 1 article =='L'amica_geniale_ (serie_di_romanzi ...

Basic Python function adjusting a variable that is not related

Why is the output of this seemingly simple code different than expected? I've searched for similar questions but haven't found one that addresses my issue. Here is the code in question: def test(f): f.append(0) f.append(0) return f i = [0] * ...

The maximum number of attempts has been surpassed

When I attempt to fetch a request from urllib3, my code successfully works. However, I have encountered issues with certain websites like that utilize different TLS versions and are unable to be fetched. I made an attempt to alter the useragent, but it di ...

The error that is being encountered is: 'float' data type cannot be read as an integer in Python version 3.4

I am encountering an issue while attempting to play a video file and the error message reads as follows: $ /usr/bin/python3.4 /home/ramakrishna/PycharmProjects/Lanedect/driving-lane-departure-warning-master/main.py Traceback (most recent call last): ...

Exploring the world of Python and Selenium with questions about chromedriver

I am planning to share my Python program with others and I would like to convert it into a .exe file using py2exe. However, I encountered an issue while using Selenium. chrome_path = r"C:UsersViktorDesktopchromedriver.exe" If users do not have the sa ...

What is the source of these spaces and what is the best way to eliminate them?

Just starting out as a beginner in Python. I am currently learning the language through a book called "Breaking Ciphers with Python". As part of a basic encryption program, I have written the following code snippet (this is just the beginning): import pyp ...

Discovering changing text on a website using Python's Selenium WebDriver

Website myList = ['Artik'] How do I verify if the content of myList is visible on the mentioned website? <span class="ipo-TeamStack_TeamWrapper">Artik<span> This specific webelement showcases 'Artik' in the given websi ...

Trouble locating SVG element in Google Calendar when using Python

I'm currently facing an issue while attempting to delete an event from my Google Calendar. An error keeps popping up indicating that the webdriver is unable to locate the element. Here's an image of the problematic element. Exception has occurred ...

Timeout occurred while waiting for the page on AWS Device Farm for Internet Explorer

I found myself in a unique situation where my AWS farm was running smoothly with capabilities options for Chrome and Firefox using my own Selenium framework, but encountered failures when setting it to INTERNETEXPLORER. self = <selenium.webdriver.remote ...

Having trouble continuously clicking the 'more' button to access all the complete reviews

I have developed a Python script using Selenium to extract all the reviews from a specific page on Google Maps. This page contains numerous reviews that are only visible when scrolling down. My script successfully retrieves all of them. However, I am curr ...

The send_keys() function in Selenium version 3.141.0 works perfectly on Windows, but unfortunately, it is not functioning correctly on Linux Debian 11

I've been experimenting with web automation using Selenium. Everything was running smoothly until I updated my packages - now the send_keys() method isn't functioning on Linux, but it's working fine on Windows with the same versions. I&apo ...

Is there a way to transfer an array of strings and integers from JavaScript to Python 3.8?

I have reviewed similar questions but haven't found a solution that works for me. My inquiry is regarding the following code snippet: function pyInput(){ const buffers = []; proc.stdout.on('data', (chunk) => buffers.push(chunk)); proc.stdo ...

issue with accessing global variable within class block

While the Python code within the 'outer' function runs smoothly on its own, placing it inside a class seems to cause issues that are difficult for me to comprehend. (I am aware that I could simply pass data as a variable inside the function or d ...

Authentication of POST API requests

As a newcomer to Python, I am eager to retrieve data from my private account on the cryptocurrency market bitbay.net. You can find the API description here: Below is my Python 3.5 code snippet: import requests import json import hashlib import time has ...

TarInfo objects dripping information

I've encountered an issue with my Python tool that reads through a tar.xz file and handles each individual file within it. The input file is 15MB compressed, expanding to 740MB when uncompressed. Unfortunately, on a particular server with limited memory r ...

Looking for a solution to fixing the Dlib error in Visual Studio C++?

Encountered an issue while attempting to install dlib using the command "pip install dlib" on Windows. The error message states:</br> ------------------------------------------------------------------------------</br> You must ...

``Is there a specific situation where pytest fixtures are most appropriate to

Having recently delved into testing, pytest fixtures have caught my attention. However, I'm not entirely clear on when to use them and how they can be beneficial. An illustration of this dilemma can be found in the following code snippet: import pytest @ ...

Substitute operation within a collection of text elements

I am trying to loop through a list of strings and replace any occurrence of a specific character, like '1', with a word. However, I'm puzzled as to why my current code is not working. for x in list_of_strings: x.replace('1', 'Ace') Just a heads up, t ...

The iterator returned by itertools.chain may present an unexpected outcome

From what I gather, Python's itertools.chain function is meant to concatenate multiple iterators. In the scenario where the first iterator contains ['a/a.jpg', 'a/b.jpg'] and the second iterator is empty, the expected result shoul ...

Is there a way to transfer data from an HTML/PHP page to a Python script?

One thing I'm trying to figure out is how to connect a two-input text field and an output text field on a PHP page (index.php) with a Python multiplication function (add.py). Basically, I want the input from the PHP page to be used in the Python funct ...

Is it Possible to Find Multiple Values with Selenium's find_elements Method?

Having the following line in python: driver.find_elements(by=By.TAG_NAME, value='a') Is there a way to modify this line to include additional values like b, c, d, etc...? I attempted this approach but it was unsuccessful: driver.find_elements(by=By.TAG_N ...

What steps should I take to resolve the "Error: Failed to establish a new connection [Errno 10061]" issue in my python code?

I'm having issues running my Python script as it keeps displaying the same error message: Failed to establish a new connection: [Errno 10061] No connection could be made because the target machine actively refused it. Note that I have disabled my f ...

I am looking to create a for loop that will automate the process of clicking on multiple links and navigating back to the previous page

Below is the code I have written to achieve a specific task: my_list = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//table[@border='1']//a"))) for option in my_list: option.click() WebDriverWait(drive ...

Generating a nested list structure from a dictionary with varying levels of nesting

I am working with a dictionary obtained from a cURL call in Python 3.8 and my goal is to extract information from just two specific keys to create a list that can be written into a csv file. The dictionary contains only one key-value pair, where the value ...

Revamp Your Workflow with Python: Discover Up-to-Date Guidelines for Automating Selenium Browser Launches

--------Responding to a Post Identified as a Duplicate Question As I am still in the process of learning the basics of programming, I was uncertain about the relevance of the information provided in the other post, particularly since it pertained to the i ...

What is the best way to import a CSV file directly into a Pandas dataframe using a function attribute?

Recently, I developed a function to compute the log returns of a given dataset. The function accepts the file name in CSV format as an argument and is expected to output a dataframe containing the log returns from the dataset. The CSV file has already been ...

cryptic SQLite3 error

I have created a Python database using SQLite3 and I am encountering an error when trying to add data. The error message states, You did not supply a value for binding 1. I have previously made the same type of database with different values and did not fa ...

Develop a query language using Python

I'm seeking a method to make filtering capabilities accessible to fellow developers and potentially clients within my workplace. Challenge I aim to introduce a basic query language for my data (stored as python dicts) that can be used by other developers ...

The Tkinter calculator is limited to performing only a single operation at a time

import tkinter import tkinter.messagebox import sys top=tkinter.Tk() from tkinter import* def clear(): e1.delete(0,END) return def seven(): v.set(v.get()+str("7")) v.get() def eight(): v.set(v.get()+str("8")) v.get() def ni ...

What is the best way to execute multiple test cases using Selenium with Python?

import unittest from selenium import webdriver from datetime import datetime class Index(unittest.TestCase): @classmethod def setUpClass(cls): chrome_options = webdriver.ChromeOptions() prefs = {"profile.default_content_setting_values.notificat ...

Python 2.7 does not support the use of the newline function

After crafting a Python script to format a text file for SQL importation, I discovered that it perfectly runs with python 3.5. However, when attempting to execute the script with python 2.7 (as required), an error is thrown which reads: TypeError: 'newline ...

other methods or enhancements for accelerating mpmath matrix inversion

Currently, I am developing Python code that involves frequent inversion of large square matrices containing 100-200 rows/columns. The precision limits of the machine are being reached, prompting me to experiment with using mpmath for arbitrary precision m ...

Python code to create a table from a string input

Suppose I have a table like this: greeting = ["hello","world"] Then, I convert it into a string: greetingstring = str(greeting) Now the challenge is to change it back into a table. What would be the approach for accomplishing this tas ...

Encountering an unidentified issuer error code (SEC_ERROR_UNKNOWN_ISSUER) while using Python Webdriver with Firefox profiles

I've searched all over the internet but am still struggling to fix the error I encountered while attempting to run a test script on my testing environment. "The certificate is not trusted because the issuer certificate is unknown. The server migh ...

An issue with Selenium web scraping arises: WebDriverException occurs after the initial iteration of the loop

Currently, I am executing a Selenium web-scraping loop on Chrome using MacOS arm64. The goal is to iterate through a list of keywords as inputs in an input box, search for each one, and retrieve the text of an attribute from the output. A few months ago, I ...

Find Instagram posts between specified dates using the Instagram Graph API

I am facing an issue while trying to fetch media posts from last month on an Instagram Business profile that I manage. Despite using 'since' and 'until' parameters, the API is returning posts outside of the specified time range. The AP ...

Learn how to use tkinter to set up a weekly task schedule starting from a user-selected date

Weekly, I am trying to automate downloading files at a specific time and day chosen by the user, similar to what is displayed in this image. My current challenge involves integrating an inner loop concerning root.mainloop(). I have experimented with both . ...

What is the best way to input text into a TensorFlow model in order to receive a prediction

I'm a newbie to TensorFlow and Python, and I've developed a model that categorizes text based on its toxicity level (obscene, toxic, threat, etc). The model seems to be working fine as it produces the summary. However, I'm having trouble pas ...

Selenium is only able to retrieve a single result at a time, disregarding any other connected outcomes

Recently delving into the world of selenium, I encountered an issue while trying to scrape a website with 10 results per page displayed in lists (li tags). Each list contains the same attributes and when certain conditions are met, I navigate to another re ...

What is the formula for determining the radius of a circular object in the shape of a turtle?

My goal is to create collision detection between turtle objects that are represented as circles. To achieve this, I need to determine the radius of these circles. import turtle as t screen=t.Screen() screen.setup(1.0,1.0) screen.bgcolor("#000") ...

Select the list item containing the desired text by clicking on it

When trying to click on a specific element based on the text displayed on this page using Python 3 and Chrome driver, I encountered an issue. For instance, when searching for "BEBES", I used the following code: WebDriverWait(browser, 10).until(EC.element_ ...

generate various instances in model serializer generate function

I have created a DRF API View in my Django project to manage Withdraw records. Below is the implementation: class WithdrawListCreateAPIView(PartnerAware, WithdrawQuerySetViewMixin, generics.ListCreateAPIView): permission_classes = (TokenMatchesOASRequi ...

Selenium is having difficulty clicking on a table row, even though it can be done manually

On my webpage, a table is populated dynamically through an API call. Each row in the finalized table is structured as follows: <tr class="ant-table-row ant-table-row-level-0" data-row-key="0"> <td class="">Value1</td> <td class="" ...

Unable to establish a connection to the Flask webserver

Testing my code on Visual Studio 2017 with the file named test: from flask import Flask, request #import main Flask class and request object from test import app app = Flask(__name__) #create the Flask app @app.route('/query-example') def ...