import requests
import re
import xlwt
workbook = xlwt.Workbook(encoding="utf-8")
worksheet = workbook.add_sheet('My Worksheet')
biao_tou = ["电影名称", "电影网址(复制链接到浏览器可直接观看)"]
for g in range(len(biao_tou)):
worksheet.write(0, g, biao_tou[g])
workbook.save("dian_ying_biao.xls")
l=int(input("请输入你想爬几页:"))
k=0
for g in range(l):
url = "https://www.1905.com/vod/list/n_1_t_16/o2p{}.html".format(g+1)
header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)' 'AppleWebKit/537.36 (KHTML, like Gecko)' 'Chrome/85.0.4183.83 Safari/537.36'}
response = requests.get(url, headers=header)
response.encoding = "utf-8"
a = re.findall('.*<a class="pic-pack-outer" target="_blank" href="https://www.1905.com/vod/play/(.*?)" title="(.*?)">',
response.text)
print(a)
for i in range(len(a)):
k = k + 1
for j in range(len(a[i])):
if j == 0:
di_zhi = "https://www.1905.com/vod/play/" + a[i][j]
print("https://www.1905.com/vod/play/" + a[i][j])
worksheet.write(k, j + 1, di_zhi)
workbook.save("dian_ying_biao.xls")
else:
ming_zi = a[i][j]
print(a[i][j])
worksheet.write(k, j - 1, ming_zi)
workbook.save("dian_ying_biao.xls")
python获取科幻电影并生成excel表格
最新推荐文章于 2024-08-28 16:14:15 发布