This question is a continuation of a previously asked question. If a string representing an ISBN number, for example 3-528-03851-5, does not match the format X-XXX-XXXXX-X, what type of exception should be raised? ...
https://i.stack.imgur.com/glIU1.jpgI'm attempting to retrieve the href of the first image from a Google images. I don't need the img src but rather the href of the a tag. Below is my code, it's able to fetch the Selenium element but the htag is returning ...
I am attempting to extract an element from a webpage using Selenium in Python <span class="_2-1_O"><span dir="auto" class="_1jlxc _3Whw5">Ana Smith</span></span> My goal is to extract the name Ana Smith using Python: contact_name ...
I attempted to set up a webdriver with a specified time out, demonstrated in the code below: self.driver = webdriver.Firefox(None, None, 5) Afterwards, I used the driver to retrieve a web page like this: self.driver.get("http://www.google.com") However ...
Scraping a web page that utilizes javascript-rendered AngularJS can be tricky. The developers of the site have implemented a feature to detect Safari/Firefox in private browsing mode and prevent scraping. Interestingly, this warning does not appear when us ...
I'm attempting to insert a series of random letters after each letter within a specified range, but the randomness is not consistent. def add_random_letters(original_string,num): new_word = '' for char in original_string: ran ...
I have two applications running on the same VPS (Ubuntu) and domain. The first is a Node.js app running on port 80, while the second is a Python (Flask) app running under Apache on port 3000. The Python app has a simple API with one endpoint /test. When I ...
I am looking to set up credit card payments for a Django Project, but I am unsure of where to begin and struggling to find information on how to do it. Which module would you recommend for integrating credit card payments? Is the module well-documented an ...
I'm attempting to extract data from the table on a Wikipedia page Link. When trying to separate each column by ',' to save it in a CSV file, I encounter an error due to the presence of '/n' tags. For example, the output for row 1 ...
Currently I am tackling the challenge of determining the eigenvalues of real symmetric matrices that are poorly conditioned, with elements spanning a wide range from very small to very large values (ranging from 1e-8 to 1e15) and potentially negative. Thes ...
Recently, I delved into exploring NLP concepts and decided to enhance my knowledge by following Python tutorials. One tutorial caught my attention when they utilized the sparse matrix of word counts, generated with CountVectorizer, as input for TfidfTransf ...
Referencing the example provided in this link - How to extract html links with a matching word from a website using python I developed a web scraping script to search for specific keywords in both recent and cached versions of a local newspaper. from bs4 ...
Hello there, I am currently working on integrating custom CSS into my Flask application. While I had no issues loading Bootstrap, I seem to be facing some difficulties with my local CSS. Below is the method I am using to load my CSS: <link rel="st ...
My page is dedicated solely to the navigation bar, which I include in my base page. The navigation bar features a drop-down menu with links obtained from the database (representing categories). However, I am facing a challenge in calling my view function ...
Snapshot of my window view I apologize if this question seems simple, but I am still learning about Django. I am currently in the process of creating a website where articles are stored as template files. My goal is to showcase all article titles on the h ...
I have a scenario where I need to deploy a stack using CDK in Account A by running cdk synth and cdk deploy in an ECS Task located in Account B. To enable this, I set up a role in Account A with administrator access and granted permissions to Account B so ...
While experimenting with the Kaggle Bag of Words module, I encountered an issue that stems from the following code snippet: kmeans_clustering = KMeans( n_clusters = num_clusters ) idx = kmeans_clustering.fit_predict( word_vectors ) word_centroid_map = dic ...
I am faced with the challenge of extracting all words from a text file that fall between two specific words. For instance, given the following text: askdfghj... Hello world my name is Alex and I am 18 years all ...askdfgj. If my goal is to capture all w ...
Not sure what to title this, but look at the example below: def example(): """ Good """ pass If I were to print example.__doc__, it would display " Good ". Is it possible to create additional 'variables' like this for other purposes? ...
Presenting the model class MyModel(models.Model): id = models.CharField(max_length=10, primary_key=True) password = models.CharField(max_length=25) area = models.CharField(max_length=100, primary_key=True) def __unicode__(self): r ...
My attempt at this solution didn't yield the desired results. Interestingly, it did work with a different JSON file (). I suspect the issue lies in the differences at the beginning and end of the current file, as there are some additional parts before ...
How can I send JSON data using sockets in Python? {"receiver": "2", "sender:": 1, "seq_num": 10, "data": "{"iv": "jdjhvwGriJ95kZwgDWlShw==", "ciphertext": "Fg7ugYYAn ...
As I work on a Python project, I encountered a situation where I need to open a file and display a message if the file does not exist. However, I am unsure whether it is necessary to close the file when an exception occurs. try: file = open(s ...
I am trying to extract specific text fields that are located within a <g> tag nested inside an <svg> tag. The website I am working on is: . My goal is to input a company name, search for it, expand the last drop-down menu, and extract informati ...
Seeking out numbers within a specific range that end with particular digits is my current quest. Consider the following examples: Identify all numbers up to 15 that end with 5. The expected result would be 2, as both 5 and 15 fulfill this criteria. ...
After using Selenium to scrape web data, I encountered an issue where it only displayed 96 out of 346 products instead of the expected 346. Does anyone have suggestions on how to fix this problem? The crawling code is placed right after the loop for clicki ...
I am encountering an issue while attempting to make a request call to Elasticsearch. I can successfully execute the same call from a basic script. However, when I convert a list into a string and pass it to the payload, I receive the following stack trace: ...
I am trying to extract the text from the XPath provided below using Selenium. However, I keep encountering the following traceback error: date = driver.find_element_by_xpath('//[@id="General"]/fieldset/dl/dd[5]/text()').text() print(date) Error ...
I am having trouble extracting data from the table located at . The code snippet I am using seems to be unable to access it for some reason. Can anyone suggest why the table scraping is not working? from bs4 import BeautifulSoup from selenium import webd ...
When it comes to refreshing a value, I'm curious about the best method to use. myList = [1, 2, 3] If I need to update the value of the list. One option is myList[2] = 5 Alternatively, del myList[2] myList[2] = 5 The elements in the list are objects t ...
During the learning process of a model, there are two main phases: A rollout phase A learning phase Although my models go through the rollout phase, they never seem to enter the learning phase. This is evident in the text output in a Jupyter Notebook wit ...
I am currently working on the labs for "Google Cloud Platform fundamentals" and encountering some issues. Every time I try to use a CoreOS instance to launch a Docker instance, I encounter an error. For instance, in the Cloud SQL lab, there is a step wher ...
In my Python code, I am working with a list of numbers that may contain duplicates. Here is an example: Input values = [1827, 1827, 1829, 1829, 1827, 1827, 1833] If a number is not repeated in the list, it should be the starting number plus the index of ...
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: ...
Currently, my setup includes env with python311, pydantic, fastapi, and mongod. return membercollection(members=await c_members.find(queryparam).to_list(1000)) This code snippet retrieves the following information: members=[membermodel(id='65b3908a77efb45 ...
After analyzing the program here, it is possible to create a tree structure resembling this: https://i.stack.imgur.com/MwbLl.png Main code: def add(x, y): return x + y def sub(x, y): return x - y def mul(x, y): return x * y FUNCTIONS = [add, sub, mul] TER ...
I am encountering some difficulties in scraping a specific table and converting it into a list of dictionaries. The table I am interested in scraping can be found on this page My objective is to scrape only the "Batting" table. Below is the code I have b ...
I've been encountering the same error in my code repeatedly and despite trying various approaches to resolve it, nothing seems to work. Can someone provide assistance? Here's the code snippet: def main(): p.init() screen = p.display.set_mode((WID ...
Attempting to create a basic Python script using Selenium, I encountered a StaleElementReferenceException after the loop runs once. Check out the code snippet being executed: from selenium import webdriver browser = webdriver.Firefox() type(browser) bro ...
Below is a dataset along with code that generates a chart: Column A Tools Category role figure Occurences After idx 0 PostgreSQL DatabaseHaveWorkedWith Developer, front-end 38.044286 4 False 1 MySQL DatabaseHaveWorkedWith Developer, front-end 45. ...
Currently working on an e-commerce application using django rest framework and vue. Utilizing djoser.authtoken for authentication purposes. Successfully managed to create a user with a POST request to /users/, but encountering issues while attempting to l ...
I'm currently working on a Selenium script to extract all filenames from every directory on a website. My strategy involves creating a list of directory objects and iteratively clicking on each directory in the list to access the filenames. However, a ...
Presently, I am utilizing this approach for sending tables in emails via Python instead of attaching them: Send table as an email body (not attachment) in Python import smtplib from smtplib import SMTPException import csv from tabulate import tabulate te ...
Here is an example from a log file: {"timestamp": "2022-01-14T00:12:21.000", "Field1": 10, "Field_Doc": {"f1": 0}} {"timestamp": "2022-01-18T00:15:51.000", "Field_Doc": {"f ...
Working on a new project utilizing the Django REST API framework. Encountering an error when running the project locally: File "/home/asad/PycharmProjects/microshop/venv/lib/python3.8/site-packages/rest_framework/routers.py", line 153, in get_rou ...
During my attempt to create a check function that would work if you had a role in a list of roles (with a user dev ID also included in the function to bypass it), I encountered an issue. mod_roles = [792816637488281642, 792626568488713617, ...
How can a relationship be established in Django where the Offer model has multiple Products, and each Product belongs to only one Offer? from django.db import models class Offer(models.Model): city = models.CharField( max_le ...
I am facing an issue where I cannot change the values in the GUI table from the main program, resulting in an error. AttributeError: 'function' object has no attribute 'commandTable' Despite attempting the solution provided in this ...
Currently, I am in the process of developing a Python application that needs to interact with a machine to carry out time-consuming tasks. While the asyncio module is ideal for network operations, I am facing a challenge when it comes to accessing the seri ...
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import by serv_obj=Service("C:Driverschromedriver_win32chromedriver.exe") driver=webdriver.Chrome(service=serv_obj) driver. ...
A timed backup system is being developed for an Excel document using Python, since there will be multiple users accessing it. The goal is to alter the file path away from the local directory. Below is the code snippet; import pandas as pd import datetime ...
Lately, I've been working on extracting a large amount of pricing data from a website by starting with one page that contains links to each item's individual page. My goal was to automate the process using a script that would click on a specific ...
As a newcomer to Google APIs, I decided to experiment with the Classroom API. While using the provided sample code, I successfully retrieved a list of courses. However, when attempting to access coursework, topics, or announcements for a specific class, I ...
I'm working with a dataframe structured like this: df = pd.DataFrame({'isin': ['a', 'a', 'c', 'd','c', 'e', 'd','f','s','d','c',&a ...
After extracting data from a large table on the web using requests and BeautifulSoup, I encountered an issue with specific parts of the information. Here is a snippet of the table: <table> <tbody> <tr> <td>265</td> <td> ...
I have a Python application in the works with FastApi, utilizing JWT and OAuth2 password flow for user authentication. Following their documentation, upon user login, a token is issued using the HS256 algorithm along with a specific user secret key. This t ...
Currently, I am attempting to create a view rendering decorator for JSON in Flask by referring to this specific code snippet: http://flask.pocoo.org/snippets/18/ My challenge lies in the necessity of serializing GAE models as JSON, which the regular jsoni ...
Building a web application where user actions can impact bar graphs, some changes are not saved. Reloading the page sometimes shows the updated bar graphs, indicating that the user's actions were saved. However, upon further reloads, the changes may or may ...
I am having trouble creating a bot to automatically fill in the blank on a website. It doesn't seem to be working correctly, and I can't figure out what the issue is. from selenium import webdriver from selenium.webdriver.common.by import By impo ...
import yfinance as yf import numpy as np import pandas as pd import seaborn as sns SP = yf.Ticker("^GSPC").history(period='1y') Gold = yf.Ticker("GC=F").history(period='1y') Oil = yf.Ticker("CL=F").history(period='1y') SP['P ...
autopy package installation error: Unable to find Rust compiler Consider updating pip with 'pip install --upgrade pip' and retry the installation process. If building from source, ensure a Rust compiler is installed and accessible o ...
I am attempting to log in to the website. Unfortunately, I am encountering an issue with filling in my username and password. Specifically, I am having trouble with entering my username. It seems like I may be selecting the wrong class name, but I am not e ...
Trying to figure out how to convert improperly parsed JSON data into a Pandas DataFrame has been quite the challenge. Utilizing Python (3.7.1), I attempted to read the JSON data in the usual way. While my code seems to work if I utilize transpose or axis= ...
My goal is to utilize SQL Server 2017 filestream in a Python environment. Since I rely heavily on SQLAlchemy for functionality, I am seeking a way to integrate filestream support into my workflow. Despite searching, I have not come across any implementatio ...
Recently, I've encountered a frustrating error in VS Code that is hindering my ability to create new files or open existing ones. The pop-up error message that appears states (this.configurationService.getValue(...) || []).filter is not a function This er ...
When I include the parameters directly in the URL, like this: import requests url = "https://api.apilayer.com/fixer/latest?symbols=GBP&base=USD" payload = { } headers= { "apikey": "*****" } response = requests.reques ...
While working on code to log in to a website, I have encountered an issue. The code successfully gets the webpage and accepts cookies, but when attempting to click the login button, the page hangs and the login page fails to load. from selenium import webd ...
In my Python code, I have the following function: from itertools import product as get_cartesian_product from arithmetic import get_iterable_sum def get_number_of_solutions(*possible_variables, target): number_of_solutions = 0 for comb in get_ca ...
I am facing an issue with importing a function in my Python project. Despite searching through numerous similar questions on SO, I have been unable to find a suitable solution for my specific problem. The existing answers either lack specificity, are over ...
My goal is to develop a python desktop application using PyQt6. I attempted to convert it into a clickable app with pyinstaller, but encountered an "app closed unexpectedly" error when trying to run the app from finder. Similarly, running the app from term ...
I currently have a file containing data in the form of multiple JSON rows. Although it consists of about 13k rows, below is a shortened example: {"first_name":"John","last_name":"Smith","age":30} {"first_name":"Tim","last_name":"Johnson","age":34} Here i ...
I'm looking to implement a page count down feature in my Python script for each page it navigates to. Below are my attempts so far. How can I achieve the desired result? In order to easily keep track of my script's progress, I have used the (len(elem_href ...
Despite having all the static files in place, only the plain HTML loads without any styles for some unknown reason. I've attempted using collectstatic and even setting up a new project, but to no avail. STATIC_URL is also properly specified along with ...
I am in possession of a large JSON dataset containing English conversations and I am curious about potential tools or methods that could facilitate translating them into Arabic. Are there any suggestions? ...
In my system, there are two modes available: User and Friends. This represents a one-to-many relationship. My goal is to retrieve the values in the following manner: record = User.query.filter_by(id=7).first() Below are the methods and properties associ ...