私は車のデータを削っています。彼らの 'id'タグは1だけインクリメントされますが、どうやってそれを行うのか分かりません。美しいスープを使ったシンプルなPython Webスクレーパー
import bs4 as bs
import urllib
source = urllib.request.urlopen('http://www.25thstauto.com/inventory.aspx?cursort=asc&pagesize=500').read()
soup = bs.BeautifulSoup(source, 'lxml')
#finds the total number of cars
count = soup.find('span', {'id': 'ctl00_cphBody_inv1_lblVehicleCount'}).getText()[:2]
count = int(count)
i = 1
for url in range(1,count):
url = soup.find_all('a', {'id': 'ctl00_cphBody_inv1_rptInventoryNew_ctl0'+i+'_nlVehicleDetailsTitle'})
print(url['href'])
i = i + 1
が
私はなぜこの質問が下落されたのかわかりません、私はあなたのためにupvoted。 –