import requests
import re
import xlwt
import os
def main():
d=input("请输入(爱情片,动作片,喜剧片,战争片,科幻片,剧情片,武侠片,冒险片,枪战片,恐怖片):")
if d=="爱情片":
e="aiqingpian"
xieRu(e)
elif d=="动作片":
e="dongzuopian"
xieRu(e)
elif d=="喜剧片":
e="xijupian"
xieRu(e)
elif d=="战争片":
e="zhanzhengpian"
xieRu(e)
elif d=="科幻片":
e="kehuanpian"
xieRu(e)
elif d=="剧情片":
e="juqingpian"
xieRu(e)
elif d=="武侠片":
e="wuxiapian"
xieRu(e)
elif d=="冒险片":
e="maoxianpian"
xieRu(e)
elif d=="枪战片":
e="qiangzhanpian"
xieRu(e)
elif d=="恐怖片":
e="kongbupian"
xieRu(e)
else:
print("您的输入不正确,请重新输入")
main()
def xieRu(e):
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])
if os.path.exists("{}.xls".format(e))==False:
workbook.save("{}.xls".format(e))
else:
os.remove("{}.xls".format(e))
workbook.save("{}.xls".format(e))
K = int(input("请输入页数:"))
h = 0
t = 0
for i in range(1, K + 1):
url = "https://www.4480qpg.com/show/{}/page/{}.html".format(e, i)
response = requests.get(url)
a = re.findall(".class=\"stui-vodlist__thumb lazyload\" href=\"(.*?)\".", response.text)
b = re.findall(".class=\"stui-vodlist__thumb lazyload\" href=\"/vod/\d{0,10}.html\" title=\"(.*?)\".",
response.text)
for j in range(len(a)):
url_d = "https://www.4480qpg.com{}".format(a[j])
worksheet.write(h + 1, 1, url_d)
if os.path.exists("{}.xls".format(e)) == False:
workbook.save("{}.xls".format(e))
else:
os.remove("{}.xls".format(e))
workbook.save("{}.xls".format(e))
h = h + 1
print(url_d)
for g in range(len(b)):
worksheet.write(t + 1, 0, b[g])
if os.path.exists("{}.xls".format(e)) == False:
workbook.save("{}.xls".format(e))
else:
os.remove("{}.xls".format(e))
workbook.save("{}.xls".format(e))
t = t + 1
print(b[g])
if __name__ == '__main__':
main()
电影代码升级,你输入什么类型电影就能看到什么类型电影
最新推荐文章于 2024-08-02 17:51:54 发布