Ich versuche, eine Python 2.7 craigslist scraper anzupassen, die ich online gefunden habe, um mit Python 3.6 zu arbeiten.Adapting Craigslist Scraper Python
Aber jedes Mal, wenn ich das Python-Skript ausführen, gibt es nichts zurück. Liegt es daran, dass ich nicht auf die richtigen HTML-Tags abziele? und wenn ja, wie würde ich die richtigen html-tags zielen?
Ich gehe davon aus, es ist dieser Teil des Codes hier:
for listing in soup.find_all('p',{'class':'result-row'}):
if listing.find('span',{'class':'result-price'}) != None:
Voll Skript ist unten.
Vielen Dank im Voraus.
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin
URL = 'https://vancouver.craigslist.ca/search/sss?query=Vespa'
BASE = 'https://vancouver.craigslist.ca/'
response = requests.get(URL)
soup = BeautifulSoup(response.content,"html.parser")
for listing in soup.find_all('p',{'class':'result-row'}):
if listing.find('span',{'class':'result-price'}) != None:
price = listing.text[2:6]
price = int(price)
if price <=3600 and price > 1000:
print (listing.text)
link_end = listing.a['href']
url = urljoin(BASE, link_end)
print (url)
print ("\n")
print('test')