标签:x64 amp firefox XML https print tree style main
import urllib.request
from urllib import parse
from lxml import etree
class Tieba():
def __init__(self):
pass
def sendRequest(self,url,begin,end):
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0"}
for value in range(begin,end+1):
index = value - 1 * 50
u = "&pn="+str(index)
fullurl = url + u
print(fullurl)
# request = urllib.request.Request(fullurl,headers=headers)
# response = urllib.request.urlopen(request)
# print(response.read())
if __name__ == "__main__":
url = "https://tieba.baidu.com/f?"
keyword = input("请输入搜寻的关键字 >>")
beginPage = int(input("请输入起始页 >>"))
endPage = int(input("请输入结束页 >>"))
kw = parse.urlencode({"kw",keyword})
fullurl = url + kw
pattern = Tieba()
pattern.sendRequest(url,beginPage,endPage)
标签:x64 amp firefox XML https print tree style main
原文地址:https://www.cnblogs.com/angle90/p/9157069.html