js设置cookie,包含多个name
cookie_val = "wechatId=**;id=**;token=**;";
var cookie_list = cookie_val.split("; ");
for(var i = 0; i < cookie_list.length; i++) {
document.cookie=cookie_list[i];
}
互阅平台,自动阅读
import requests
from lxml import etree
import time
import random
def get_read(url, title='', i=1):
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63060012)",
"Cookie": "phone=178********; uid=****; PHPSESSID=beaea8b1b4b1bbfe4034911a****; pswd=6a15b4dd5648fb00b0462ded8b0****"
}
content = requests.get(url=url, headers=headers).text
html = etree.HTML(content)
score = html.xpath('/html/body/div[2]/div[2]/div[2]/text()')[0]
title_real = html.xpath('/html/body/ul/li['+str(i)+']/a/div[1]/text()')[0]
if title_real == title:
i = random.randint(1, 10)
else:
title = title_real
i = 1
href = html.xpath('/html/body/ul/li['+str(i)+']/a/@href')[0]
print(score)
print(title_real)
href = url + href
print(href)
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
print("#" * 100)
ct = requests.get(url=href, headers=headers).text
tip = etree.HTML(ct).xpath('/html/body/div[1]/div[2]/div/div/div/div/div[2]')
if len(tip) != 0 and "40篇" in tip[0].text:
print(tip[0].text)
time.sleep(3600)
time.sleep(12)
return get_read(url, title=title, i=i)
if __name__ == '__main__':
title = ''
i = 1
get_read("http://qmb63.com/See/", title=title, i=i)
|