Python Forum
NameError: name 'download' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError: name 'download' is not defined
#1
I am trying to extract the country area from example website. And I got following errors. I am using python version 3.6
from bs4 import BeautifulSoup
url = 'http://example.webscraping.com/places/default/view/Australia-14'
html = download(url)
soup = BeautifulSoup(html)
# locate the area row
tr = soup.find(attrs={'id':'places_area_row'})
td = tr.find(attrs={'class':'w2p_fw'}) #locate the date elements
area = td.text #extract the text form the data element
print (area)
Error: "NameError: name 'download' is not defined"
Reply
#2
This may be the place where to look.
Reply
#3
where did you cause download to be defined?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
Just remove download,and use Requests(is what should by used anyway in the download reference).
from bs4 import BeautifulSoup
import requests

url = 'http://example.webscraping.com/places/default/view/Australia-14'
url_get = requests.get(url)
soup = BeautifulSoup(url_get.content, 'html.parser')
contry = soup.find('tr', id="places_country__row")
print(contry.text)
Output:
Country: Australia
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  NameError :name 'name' is not defined Suzzy_ 4 18,921 Dec-27-2019, 09:04 AM
Last Post: LeanbridgeTech
  NameError: Name 'path' is not defined aniyanetworks 9 59,713 Jun-29-2018, 03:21 PM
Last Post: gontajones
  NameError: name 'bsObj' is not defined Blue Dog 14 15,689 Oct-24-2016, 08:34 AM
Last Post: Blue Dog

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020