python - Beautifulsoup iterating over multiple pages -




i try iterate on multiple pages problem code skip pages when i'm executing code.

my code:

from bs4 import beautifulsoup selenium import webdriver import requests, csv, re  game_links = [] link_pages = [] base_url = "http://www.basket.fi/sarjat/ohjelma_tulokset/?season_id=93783&league_id=4#mbt:2-303$f&stage=177155:$p&0="  in range(1,10,1):     link_pages.append(base_url+str(i))  link in link_pages:     browser = webdriver.phantomjs()     browser.get(link)     table = beautifulsoup(browser.page_source, 'lxml')     td in table.find_all("td",{"class":"first"}):         li in td.find_all("a", {"game_id":re.compile("\d+")}):             href=li.get("href")             game_links.append(href)     print(len(game_links))  

result now:

20 40 60 80 100 120 140 140 160 

my goal:

20 40 60 80 100 120 140 160 180 

when try scrape pages separately works, when try iterate on pages skips randomly pages? wrong?





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

Asterisk AGI Python Script to Dialplan does not work -