Python Forum
I found some thing new that I am not sure about
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I found some thing new that I am not sure about
#1
I have been working with this code from tut and picking the code apart. I got everything to work fine, the in the tut. they made a few changes. That is when the problem started. Thier are a few function I have never seen and the code is identical to the one in the tut. One thing I have never seen befor it the function re.compile. well anyway here is the code and the error.

import urllib2
from BeautifulSoup import BeautifulSoup
import re


opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]

url = ('https://en.wikipedia.org/wiki/List_of_American_comedy_films')

ourUrl = opener.open(url).read()

soup = BeautifulSoup(ourUrl)

for link in soup.findall('a', attrs = ('href',  re.compile("^/wiki/^"))):
   print link
  

#body = soup.find(text="Origin").findNext('td')
#outfile = open('savestuff_2.txt', 'w')
#outfile.write(body.text)
Now the error

Traceback (most recent call last):
 File "C:/Users/renny/Desktop/python27/My_ webscraper/movie_scraper.py", line 15, in <module>
   for link in soup.findall('a', attrs = ('href',  re.compile("^/wiki/^"))):
TypeError: 'NoneType' object is not callable
I am not sure what object can not be called, what is a nonetype object?
Thank you
renny Wall
Reply


Messages In This Thread
I found some thing new that I am not sure about - by Blue Dog - Jul-04-2017, 12:49 AM

Forum Jump:

User Panel Messages

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