Questions tagged [python-requests]

Exclusively designed for the Python Requests library, this tool offers a comprehensive set of features and a user-friendly interface for handling HTTP requests in Python.

Inquiries Regarding Requests and Beautiful Soup

import requests from bs4 import BeautifulSoup import time import sys url = "https://www.doviz.com/" response = requests.get(url) html_content = response.content soup = BeautifulSoup(html_content,"html.parser") names = soup.find ...

In Python, when you utilize the requests.get('url') function and then print out r.text, what will be the outcome?

I'm attempting to scrape this specific website. The following code appears to be functional: import requests header = { 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0', } r = requests.get('http://www.m ...

Learn how to streamline the task of verifying Twitter profiles by creating an automated system that can also send messages if desired

Is there a way to use Selenium with Python and Requests to check if a specific profile has the message function? https://i.stack.imgur.com/0Q4RB.png ...

Selenium encountered an error in retrieving the section id from the web page

I am facing an issue with this specific piece of code: import re from lxml import html from bs4 import BeautifulSoup as BS from selenium import webdriver from selenium.webdriver.firefox.firefox_binary import FirefoxBinary import requests import sys import ...

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. ...

What is the best way to use requests in python to enter text in a textarea, then scrape the html with bs4, all while the input remains hidden?

I'm working on a script that interacts with by sending a string and receiving one or all of the "fancy text" variations provided by the site. I am struggling to identify the input area within the HTML structure, especially since I aim to use requests for ...

Addressing the error message "TypeError: 'NoneType' object is not callable" while using a web scraper

Currently, I am in the process of developing a Python script that navigates to a specific website. The objective is to scan all the results of coins on the webpage, click on each result, and verify if there is a Telegram link available. If a Telegram link ...

Sending a POST request in Python does not modify the original date displayed in the response

view image description hereWhen attempting to submit form data on the , I receive a response, but it doesn't reflect the dates I provided in my post. Below is the code snippet I am using: import requests.sessions url = "https://seffaflik.epias.com.tr ...

A Python script utilizing BeautifulSoup library for parsing HTML tags

Currently attempting to extract specific data by parsing the content inside a script tag. Utilizing a legitimate Xbox Live account for this purpose. from selenium import webdriver from selenium.webdriver.common.keys import Keys import requests import time ...

The pre tag cannot be retrieved by BeautifulSoup

Trying to extract text from a specific webpage, I encountered an issue. Despite using the following code snippet: url = "http://www.koeri.boun.edu.tr/sismo/2/latest-earthquakes/list-of-latest-events/" response = requests.get(url) html = response ...

What information can be gathered from the Python requests stack trace?

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: ...

Issue with the beautiful soup 4 library

I'm feeling puzzled as this code seems to work inconsistently. It utilizes the beautiful soup module and I'm curious why it functions in certain situations but fails at other times. from bs4 import BeautifulSoup import requests import lxml import ...

Once more: "The JSON object should be a string, bytes, or bytearray, not a list" encountered in the requests library

I'm struggling with a simple request and can't figure out what's wrong data1 = df.loc[N, 'online_raw_json'] print(type(data1)) print(data1) data1 = json.dumps(data1) print(type(data1)) print(data1) response = requests.post("http://127.0.0.1:5000/pred ...

The Chrome developer tools are unable to locate the HttpRequest

While working in Python, I am utilizing the requests library to make a POST request to a specific URL. However, upon clicking the button, it seems that nothing is happening as per Chrome Developer Tools. No XHR requests are being made and no data is being ...

The Java to Python conversion of a POST request results in receiving a null response

As I embark on my journey with Python Flask, I have encountered a hurdle while coding using the requests and flask modules. My current project revolves around utilizing the web API provided by the Panther platform. The project initially demonstrated an ex ...

Guide for testing URL connectivity using Python

My scenario is similar to the one described in this Stack Overflow post. However, I want to log an error message if the URL cannot be reached. Here's my attempt: # Defining the URL and checking the connection by printing the status url = 'https ...

What is the process for accessing information from Symantec through their API?

Experiencing a 400 status code error currently. Feeling a bit stuck on what steps to take next. The 400 status code typically relates to syntax issues. How can I properly format my output into JSON file structure? import requests, json, urllib3 urllib3.d ...

Python does not recognize the Json-like response

After receiving a response using urllib3 (also tested with requests), I decoded it and then used json.loads on it. The data, post-decoding with decode('utf-8'), that I would like to convert into JSON is as follows: json_thing = b'{\n& ...

Issue with requests due to MissingSchema exception

I have a unique person class that provides detailed information about individuals, as shown below: Datatracker.py class @dataclass class Person: resource_uri: str id: int name: str name_from_draft: str ascii: str ascii_short: Opti ...

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 ...

Error encountered: Failure to construct URL for endpoint 'Bookdetails'. Have you overlooked supplying values for the parameter 'book_id'?

I have been troubleshooting this issue and reviewed similar threads, yet despite verifying all options, the problem persists. My code includes: application.py @app.route("/Booksearch/<int:book_id>", methods=["GET", "POST"]) def Bookdetails(book_id ...

Exploring the contrast in Python Requests package's treatment of data and json parameters

What distinguishes the data from the json parameters in Python's Requests library? The documentation available at this link does not provide a clear answer. Consider this code snippet: import requests import json d = {'a': 1} response = requests.post(url ...

problems arise when staying logged in is not possible

I've been attempting to extract some email addresses from mdpi.com, but these emails are only accessible to users who are logged in. Unfortunately, my attempts have not been successful so far. When I try to do this while logged out, the following issue ari ...

Tips for ensuring a page has fully loaded before extracting data using requests.get in Python without relying on an API

Currently, I am using Python along with the requests library for web-scraping. I've encountered an issue regarding the loading of a page; I would like to implement a delay before receiving the result from requests.get(). I have come across some indiv ...

Having trouble finding elements with XPath in Python

While attempting to extract website information from firms listed on Bloomberg using XPath, I encountered a challenge as the results came back empty. After conducting multiple tests, it became evident that I was unable to locate any elements on the webpage ...

Sending JSON data with Python and fetching the response

I've been working on a Python script to make a post request, but I'm not receiving any response. Everything seems correct in my code, so I suspect there might be an issue with the service itself causing the lack of response. Can anyone spot if th ...

Python : Grep causing UnicodeEncodeError in my code

In my program written in Python, I am utilizing a basic script to retrieve reservation results for a specific CID using the file simple.py: data = {"minorRev":"current minorRev #","cid":"xxx","apiKey":"xxx","customerIpAddress":" ","creationDateStart":"03 ...

Unable to retrieve profile names from duplicate URLs with requests

Having an issue with logging into Facebook using selenium and transferring cookies to the requests module in order to collect profile names from specific URLs. The profile names on these URLs are static but require authentication. While my script successf ...

Tips for detecting HTML updates using Python requests

My goal is to monitor a page for updates while maintaining the same session and cookies, without sending a completely new request. How can I determine if there are HTML updates within my current request? The page will redirect but keep the same URL. This ...

Is it possible to extract data from several tables on a Wikipedia page, including their headers, using Python's requests and BeautifulSoup libraries?

Using Python libraries like requests and BeautifulSoup, I am attempting to scrape the tables from the following Wikipedia page: https://en.wikipedia.org/wiki/Mobile_country_code. While I am able to retrieve all the data within the tables, my goal now is to ...

Accessing a webpage using python requests to authenticate users

I'm attempting to access a website using python 3, requests, and lxml for logging in. However, despite sending a post request to the login page, I am unable to access the pages that are meant to be visible after logging in. What could be the issue? i ...

Automatically retrieve a URL from a website using Python

My approach to streamline my program and enhance user experience was by creating an executable file that consolidates all functions, including the download of various applications and their installation. However, I encountered a challenge where the link is ...

The transition from using Selenium to sending requests

I am currently exploring the requests module as an alternative to Selenium for web scraping. Below is the code snippet I have been working on that extracts a table from a webpage. I'm struggling to optimize this code using requests in a more efficient an ...

Transferring a list of decimal numbers from a Python server to another using Flask and the requests library

I am working on a project that involves periodically sending an Array of doubles from a Python service to another. Despite being a newcomer to Python, I have delved into topics like Flask and requests. Below is a basic code example that I put together jus ...

What causes the HTTP 405 error in my requests and what is the proper way to utilize an API?

Greetings, I am a novice programmer facing difficulties with sending data to a site using an API. Unfortunately, things did not go as planned and now I find myself in trouble. Here is the code snippet I have been working on: data = { "‫‪indus ...

resend requests at specified intervals

I'm currently learning from this insightful guide Utilizing session.mount, I have the capability to instruct requests to perform multiple retries. However, it appears challenging to regulate the time interval between each request. Currently, I am re ...

What are the signs that indicate a webpage is offline or unresponsive?

I have developed a Python code that checks the availability of web pages stored in a tuple by browsing them using Selenium. The objective is to regularly check if these pages are online and responding. Here is a snippet of the code: from selenium import w ...

Discovering void or absence when extracting information from a website using Selenium in Python

I am trying to retrieve the website's activity and uptime data, but I'm only able to get the activity status and not the uptime information. I have targeted the exact class of the website, but it shows null. Can someone please assist me in modifying my cod ...

What is the best way to handle exceptions when a specific name is not defined within the context?

My application is encountering issues with the python-requests library, leading to a traceback that looks like this: Traceback (most recent call last): File "/usr/lib/python3.2/http/client.py", line 529, in _read_chunked chunk_left = int(line, 16) V ...

Using the Requests library: How to send true or false values in the parameters

Here's a snippet of code I've been working on that involves sending a request to an API: request_parameters = { "headers": myheaders, "params": { "myparam": True } } response = requests.get(myurl, **request_pa ...

transferring a printing task from Python to Google Cloud Print

The Print Job Dilemma My current challenge involves sending a print job from a python script to a printer that is registered in 'Google Cloud Print'. Required Components for Success A valid google account Registration of Google cloud API, ...

Can you provide guidance on the correct syntax for sending a JSON post request to StubHub?

{ "listing":{ "deliveryOption":"option", "event":{ "date":"date", "name":"name of event", "venue":"venue" }, "externalListingId":"000000000", "inhandDate":"inhand date", "pricePerTicke ...

The Python code utilizing the requests.get().json() function seems to be stuck in an

I am currently working on scraping data from a table located at import pandas as pd import requests import json headers = {'Host': 'stats.nba.com','User-Agent': 'Firefox/55.0','Accept': 'application/ ...

The error message "TypeError: list indices must be integers or slices, not str" occurs when trying to access list elements

I am encountering an issue while attempting to retrieve data from the API. Specifically, I am looking to obtain the block height from this particular API. import requests import json fetch_json_data = requests.get('https://api.minaexplorer.com/blocks?l ...

What is the best way to send multiple API requests and save the data to a JSON file?

In my Python script, I am attempting to make multiple API calls using the requests library. Currently, my code involves connecting to different API URLs and writing the JSON responses to separate files for further data manipulation. The connection and writ ...

What could be the reason for receiving empty content when using requests.get with the correct header?

While attempting to crawl a website, I copied the Request Headers information from Chrome directly. However, after using requests.get, the returned content is empty. Surprisingly, the header printed from requests is correct. Any idea why this might be happ ...

Send a JSON payload to an API endpoint using the requests module

Currently, I am in need of sending a JSON object as input to an API in order to receive another JSON response. My usual method for accessing an API using requests is shown below: response=requests.get('url',auth=uauth,headers=headers).json() B ...

What causes a URL to function in a browser but fail when using the requests get method?

Whilst conducting tests, I stumbled upon a curious phenomenon: url = ' http://wi312.rockdizfile.com/d/uclf2kr7fp4r2ge47pcuihdpky2chcsjur5nrds2hx53f26qgxnrktew/Kimbra%20-%20Love%20in%20High%20Places.mp3' When this URL is entered into a browser, the file d ...

Combining login information from a successful state using selenium with a Requests session - a guide

Indeed, selenium can fulfill my current requirement, but it comes with certain limitations: it is slow and necessitates the opening of a real browser on the user's machine. My approach involves using selenium to log in and fetch some state data, whic ...

Python Struggles with JSON Parsing

I'm working on extracting a specific element from JSON data and organizing it into a separate column within my pandas DataFrame. This is the code that I currently have: #Import necessary libraries import json import requests from IPython.display impo ...

In Python 3, when using the requests library, a response of

When I run curl command, I receive back a unique hash value: $ curl "http://127.0.0.1:8002/hash/" -X POST -d 'data={"key":"value"}' { "hash": "9724c1e20e6e3e4d7f57ed25f9d4efb006e508590d528c90da597f6a775c13e5" } However, when using Python requests, I en ...

Encountering a 500 error while trying to make a POST request with FastAPI on Vercel

I am currently utilizing React on the frontend and Fastapi on the backend main.py from typing import Union from fastapi import FastAPI from fastapi.encoders import jsonable_encoder from fastapi.middleware.cors import CORSMiddleware from pydantic import ...

Beautifulsoup may occasionally output a None value at times

I attempted to extract an image from a Reddit post using this code snippet. However, when I execute the code, it sometimes displays an HTML snippet and other times it prints None without any errors. Can anyone explain why this is happening? Below is the ...

Asking for an API request in python that necessitates an oauth token

As I work on a program to send data to a specific URL and receive a response, I encountered an issue while using Python. The problem arose when trying to include a token in the request as required by Postman, resulting in a [401] response. The main obstac ...

Utilize Python to extract JSON data from a CURL response

I need to extract the value of the id, which is "id": 59 from a JSON output obtained using curl command. The JSON output looks like this: [{"id":59,"description":"This is a demo project","name":"Demo_Project","name_with_namespace":"sam / Demo_Project","pa ...

Using Flask to send and receive JSON requests with boolean values

How can I include a boolean value in the request body using the Python requests library? I attempted: request_body = {'someBooleanValue': true}. => NameError: name 'true' is not defined request_body = {'someBooleanValue': ...

Tips for capturing network traffic with Selenium WebDriver and BrowserMob Proxy in Python

For my project, I am working on capturing network traffic using Selenium Webdriver with Python. In order to achieve this, I need to utilize a proxy such as BrowserMobProxy. Everything works smoothly when using webdriver.Chrome: from browsermobproxy impor ...

Leverage the power of the OR operator in a Lambda function for Python web scraping

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 ...

Use Python to access a website button and download a xlsx file with just one click

Currently, I am working on a Python script to generate a daily COVID-19 dashboard for my country and state. Unfortunately, I have hit a roadblock in downloading one of the required files. To download this file, I need to visit the website () and click on ...

Utilizing Python requests for retrieving dynamic website data

Currently, I am utilizing Python (BeautifulSoup) to extract data from various websites. However, there are instances where accessing search results can be challenging. For example: import requests from bs4 import BeautifulSoup url1 = 'https://auto.ria.co ...

What is the best way to include optional parameters in a RESTful API?

I'm currently utilizing the REST API found at this link. Here is an example code snippet for reference: server = "https://rest.ensembl.org" ext = "/vep/human/hgvs/ENSP00000401091.1:p.Tyr124Cys?" r = requests.get(server+ext, header ...

Scraping a website with Python that contains redirection to another website

I'm struggling with scraping the contents of a specific web page. Here is an example of my Python code: response = requests.post('http://a836-acris.nyc.gov/bblsearch/bblsearch.asp?borough=1&block=733&lot=66',{'User-Agent' ...

Tips for extracting numerical data from Google search results

import requests from bs4 import BeautifulSoup # Fetch data from Google Search response = requests.get("https://www.google.com/search?q=book") soup = BeautifulSoup(response.content, 'html.parser') phrase_extract = soup.find_all(id="result-stats") ...

Encountering a problem with the Python request library

Hello there, Lately, I've been experiencing timeouts when making requests to the ebay website. Here is the simple code that I am using: import requests headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; ...

What is the process for obtaining the most recent stock price through Fidelity's screening tool?

Trying to extract the latest stock price using Fidelity's screener. For instance, the current market value of AAPL stands at $165.02, accessible via this link. Upon inspecting the webpage, the price is displayed within this tag: <div _ngcontent-cx ...

What is the best method to retrieve all symbols and last prices from this JSON file?

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 ...

Learn how to extract information from the Australian Bureau of Statistics by utilizing pandasmdx

Has anyone successfully retrieved ABS data using the pandasdmx library? Below is an example code that retrieves data from the European Central Bank (ECB) and works as expected. from pandasdmx import Request ecb = Request('ECB') flow_response ...

Creating a Python dictionary with file names as keys: A step-by-step guide

My goal is to send all files located in a specific folder on my local disk to a designated web address using Requests and Glob. Each time I upload a new file to the URL, I intend to update a dictionary with a new entry consisting of the "file name (key)" a ...

Python Requests.get() fails to fully respond to XHR request due to an incomplete response

My current project involves scraping German zip codes (PLZ) based on a specific street in a particular city using Python's requests library. The data I am working with can be found on this server, and I'm applying techniques learned from here. The goal is ...

Sending a post request with a PIL Image in Python

<PIL.WebPImagePlugin.WebPImageFile image mode=RGB size=1600x1600 at 0x1F4E779BA00> is the type of file I'm working with. When I make a post request, I encounter this error: TypeError: a bytes-like object is required, not 'WebPImageFile'. Any sugges ...

How can I properly format the JSON data for a POST request using the Python requests package? Should I include the jsonRequest

My current challenge involves attempting to send a POST request to the USGS EarthExplorer inventory API, beginning with a straightforward log-in process. They provide a handy test page at: This test page showcases some formatting examples. When exploring ...

The response from a Python requests.get() call is coming back as empty

Currently, I am in the process of developing a script that interacts with the Jenkins plugin API to retrieve a list of plugin dependencies. To achieve this, I have utilized the Python requests module. However, I am encountering an issue where the response ...

Can all exceptions for requests be consistently captured? (And more broadly, for a module)

I'm dealing with some code that involves making a requests.get() call, which could potentially fail in different ways. My goal is to catch any exceptions related to requests, without necessarily needing to know the specific reason for the failure. I ...

Is the content of the website altered by using the request.get method? (Web scraping)

While attempting to extract data from a particular website using the requests.get method, I encountered an issue. The information retrieved from the website seems to be inconsistent and does not align with the actual data displayed on the site. For instan ...

Issue encountered while sending HTML email using Mailgun Python API

My current setup allows me to send text emails with the Mailgun Python API without any issues: def send_simple_message(email_text, attachment_filename=""): requests.post("https://api.mailgun.net/v3/mydomain.in/messages", auth=("api", "key-1234"), fi ...