#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
import csv
import bs4
import codecs
#检查url地址并返回网页contents
def check_link(url):
try:
r = requests.get(url)
r.raise_for_status()
r.encoding = r.apparent_encoding
return r.text
except:
print('无法链接服务器!!!')
# 判断一个unicode是否是英文字母
def is_alphabet(uchar):
if ('\u0041' <= uchar<='\u005a') or ('\u0061' <= uchar<='\u007a'):
return True
else:
return False
#爬取表格数据
def get_contents(urlist):
'''urlist: a list containing all the useful urls'''
result = []
for url in urlist:
content = check_link(url)
soup = BeautifulSoup(content,'lxml')
trs = soup.find_all('tr')
for tr in trs:
ui = []
fo
Python爬取扇贝“【无老师】7天搞定TOEFL单词”
最新推荐文章于 2023-03-24 13:59:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)