代码只是反复打印相同的电子邮件地址,而不会转到下一页。有人看到我代码中的错误吗?import requests

from bs4 import BeautifulSoup as soup

def get_emails(_links:list):

for i in range(len(_links)):

new_d = soup(requests.get(_links[i]).text, 'html.parser').find_all('a', {'class':'my_modal_open'})

if new_d:

yield new_d[-1]['title']

start=20

while True:

d = soup(requests.get('http://www.schulliste.eu/type/gymnasien/?bundesland=&start=20').text, 'html.parser')

results = [i['href'] for i in d.find_all('a')][52:-9]

results = [link for link in results if link.startswith('http://')]

print(list(get_emails(results)))

next_page=d.find('div', {'class': 'paging'}, 'weiter')

if next_page:

d=next_page.get('href')

start+=20

else:

break

当您按下按钮“weiter”(下一页)时,urlending从“…start=20”变为“start=40”。它是在20秒的步骤,因为每个网站有20个结果。

更多推荐

python跳转下一页_Python网页浏览转到下一页