#豆瓣cookie模拟登录,热门精选
import requests
import time
from lxml import etree
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36'
'cookie':'###################################'
}
urls = ['https://www.douban.com/interest/1/1/?p={}'.format(str(i)) for i in range(1,10)]
for url in urls:
res = requests.get(url,headers=headers)
html = etree.HTML(res.text)
infos = html.xpath('//div[@id="statuses"]/div[1]/div')
for info in infos:
name = info.xpath('div/div/div[1]/div[2]/a/text()')
context = info.xpath('div/div/div[2]/div[1]/div/p/text()')
print (name,context)
time.sleep(2)