验证中...
Languages: Python
Categories: 编程语言基础
Latest update 2019-10-06 00:30
gistfile1.txt
Raw Copy
import requests
from lxml import etree
def get_title(url):
page = req(url)
page.encoding = "utf-8"
page_x = etree.HTML(page.text)
con = page_x.xpath('//div[@class="title"]/a/text()')
for c in con:
save(c)
def req(url):
head = {
'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"
}
con = requests.get(url, headers=head)
return con
def save(c):
con = str(c)
with open("美女标题.txt","a",encoding='utf-8') as f:
f.write("\n")
f.write(con)
f.write("\n")
f.close()
if __name__ == "__main__":
for m in range(2,210):
url = 'https://www.yeitu.com/meinv/xinggan/%d.html' % m
get_title(url)

Comment list( 0 )

Sign in for post a comment

Help Search