python 爬虫 糗百成人

import requests
def test_links(url):
    print(url)
    response = requests.get(url)
    from lxml import etree
    html = etree.HTML(response.content)
    links = html.xpath('.//*[@id="wrapper"]/div/div[1]/div[9]/div/a[contains(text(),"下一页")]/@href')
    print(links)
    if len(links) < 1 :
        pass
    else:
        host = 'http://www.qiubaichengren.com/'
        new_url = host+links[0];
        test_links(new_url)
test_links("http://www.qiubaichengren.net/87.html")

  

猜你喜欢

转载自www.cnblogs.com/php-linux/p/8919958.html