Ich bin neu in Python. Ich habe meinen eigenen Web-Crawler gemacht, der Yelp für die Praxis kratzen soll.Web Crawler --- TypeError: Coercing nach Unicode: brauche String oder Puffer, NoneType gefunden
Ich erhalte diesen Fehler und kann nicht scheinen, über die erste Seite zu erhalten:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 26, in yelpSpider
TypeError: coercing to Unicode: need string or buffer, NoneType found
Hier ist mein Code:
import requests
from BeautifulSoup import BeautifulSoup
def yelpSpider(maxPages):
page = 0
listURL = []
listRATE = []
listAREA = []
listADDRESS = []
listType = []
while page <= maxPages:
url = 'https://www.yelp.com/search?find_desc=Restaurants&find_loc=Manhattan,+NY&start=0' + str(page)
sourceCode = requests.get(url)
plainText = sourceCode.text
soup = BeautifulSoup(plainText)
for bizName in soup.findAll('a',{'class':'biz-name js-analytics-click'}):
href = 'https://www.yelp.com.com' + bizName.get('href')
listURL.append(href)
for rating in soup.findAll('img',{'class':'offscreen'}):
stars = rating.get('alt')
listRATE.append(stars)
for area in soup.findAll('span',{'class':'neighborhood-str-list'}):
listAREA.append(area.string)
for type in soup.findAll('span',{'class':'category-str-list'}):
listType.append(type)
for tracker in range(int(page),int(page) + 10):
print(listURL[tracker])
print(' ')
print(listAREA[tracker] + ' | ' + listRATE[tracker])
page += 10
yelpSpider(20)
Thank Sie für Ihre Hilfe!
Ändern Sie den letzten Druck ändern: ' print ('{} | {}'. format (ListeAREA [Tracker], listRATE [Tracker])) ' –