Web_Crawler

来源:互联网 发布:子弹 知乎 编辑:程序博客网 时间:2024/06/16 04:17
import requestsfrom bs4 import BeautifulSoupdef trade_spider(max_page):    page = 1    i = 0    while page <= max_page:        url = 'https://www.thenewboston.com/search.php?type=0&sort=reputation&page=' + str(page)        source_code = requests.get(url)        plain_text = source_code.text        soup = BeautifulSoup(plain_text)        for link in soup.findAll('a',{'class':'desc-title'}):            href = 'https://www.thenewboston.com'+ link.get('href')            title = link.string            print(title)            print(href)            i += 1            print('\n')        page += 1    print(i)trade_spider(5)
0 0
原创粉丝点击