url = "http://www.7k7k.com/" headers = { "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0" } repens = requests.get(url=url,headers=headers) repens.encoding = "utf-8" reqs = etree.HTML(repens.text) he = reqs.xpath("/html/body/div[2]/div[1]/div/div[6]/div[1]/div/div/div/div[2]/div[1]/ul[1]") for i in he: a = i.xpath('li/a/@title') print(a) 这只是一部分游戏名字以后有可能会完善一下
2021.8.24 爬虫7k7k
import requests
from lxml import etree
url = "http://www.7k7k.com/" headers = { "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0" } repens = requests.get(url=url,headers=headers) repens.encoding = "utf-8" reqs = etree.HTML(repens.text) he = reqs.xpath("/html/body/div[2]/div[1]/div/div[6]/div[1]/div/div/div/div[2]/div[1]/ul[1]") for i in he: a = i.xpath('li/a/@title') print(a) 这只是一部分游戏名字以后有可能会完善一下
url = "http://www.7k7k.com/" headers = { "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0" } repens = requests.get(url=url,headers=headers) repens.encoding = "utf-8" reqs = etree.HTML(repens.text) he = reqs.xpath("/html/body/div[2]/div[1]/div/div[6]/div[1]/div/div/div/div[2]/div[1]/ul[1]") for i in he: a = i.xpath('li/a/@title') print(a) 这只是一部分游戏名字以后有可能会完善一下