标签:htm range path username less user primary highlight pos
import requests from lxml import etree ‘‘‘ 黑板爬虫闯关02 网址:http://www.heibanke.com/lesson/crawler_ex01/ ‘‘‘ url = "http://www.heibanke.com/lesson/crawler_ex01/" data = { ‘username‘:"shuimo", ‘password‘: 0, } for i in range(30): data[‘password‘] = i res = requests.post(url,data=data) res.encoding="utf8" html = etree.HTML(res.content) info = html.xpath("//h3/text()")[0][4:8] if info != "密码错误": url = "http://www.heibanke.com" + str(html.xpath(‘//a[@class="btn btn-primary"]/@href‘)[0]) print("下一关的网址是:%s"%url) print("闯关成功的数字是%d"%i) break
标签:htm range path username less user primary highlight pos
原文地址:https://www.cnblogs.com/shuimohei/p/10506728.html