close

[Solved] Name: name ‘requests’ is not defined

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Name: name ‘requests’ is not defined in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Name: name ‘requests’ is not defined Error Occurs?

Today I get the following error Name: name ‘requests’ is not defined in python.

How To Solve Name: name ‘requests’ is not defined Error ?

  1. How To Solve Name: name 'requests' is not defined Error ?

    To Solve Name: name 'requests' is not defined Errorinstall requests
    pip install requestsfrom bs4 import BeautifulSoup import requests page = requests.get("https://www.google.dz/search?q=see") soup = BeautifulSoup(page.content) links = soup.findAll("a")

  2. Name: name 'requests' is not defined

    To Solve Name: name 'requests' is not defined Errorinstall requests
    pip install requestsfrom bs4 import BeautifulSoup import requests page = requests.get("https://www.google.dz/search?q=see") soup = BeautifulSoup(page.content) links = soup.findAll("a")

Solution 1

install requests

pip install requests

and change your code like this:

from bs4 import BeautifulSoup 
import requests 
page = requests.get("https://www.google.dz/search?q=see") 
soup = BeautifulSoup(page.content) 
links = soup.findAll("a") 
for link in links: 
    if link['href'].startswith('/url?q='): 
        print (link['href'].replace('/url?q=',''))

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read