# !bin/usr/env python3 # coding=utf-8 import re import urllib.request from bs4 import BeautifulSoup '''获取网址''' def get_url(url): Url = [] #url = 'http://www.kekenet.com/video/16692/' f = urllib.request.urlopen(url) html = f.read() soup = BeautifulSoup(html,'html.parser') content = soup.find_all('ul',id='menu-list') for tag in content: li = tag.find_all('li') #类型<class 'bs4.element.ResultSet'>
python3 --小爬虫(爬取美剧字幕)
最新推荐文章于 2022-03-31 21:49:18 发布
该博客介绍了使用Python3编写的小爬虫,通过BeautifulSoup库解析HTML,从特定网站抓取美剧字幕的相关链接。首先获取网页URL,然后对每个页面进行迭代,提取页面标题及含有英文字幕和中文字幕的div元素,并将内容写入文件M_S6.txt。

最低0.47元/天 解锁文章
7534





