Python3~爬取某翻译网页的单词与解释

from urllib import request
from bs4 import BeautifulSoup
import ssl

ssl._create_default_https_context=ssl._create_unverified_context

#一、网络请求页面
base_url = "https://www.shanbay.com/wordlist/110521/232414/?page=1"
response = request.urlopen(base_url)
html = response.read()

#二、bs4对象创建
soup = BeautifulSoup(html,'lxml')
tr_list=soup.select('.row')
for tr in tr_list:
    td_list=tr.select('td')
    # print(td_list)
    if td_list!=[]:
        word=td_list[0].contents[0].get_text()
        content=td_list[1].get_text()
        print(word,content)


    print('~~~~~~~~~~~~~~~~~~~~~~~')
 
 

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/apple/PycharmProjects/stage4/spider/2018_3_9/01homework.py
computational  adj. 计算的,电脑的
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
computational  adj. 计算的,电脑的
~~~~~~~~~~~~~~~~~~~~~~~
computational  adj. 计算的,电脑的
~~~~~~~~~~~~~~~~~~~~~~~
mode n. 模式
~~~~~~~~~~~~~~~~~~~~~~~
primitive n. 原始、基元,是后续操作的基础
~~~~~~~~~~~~~~~~~~~~~~~
gigabyte n. 千兆字节,是数据单位
~~~~~~~~~~~~~~~~~~~~~~~
storage n. 储存体,  仓库
~~~~~~~~~~~~~~~~~~~~~~~
retrieve n. 检索,恢复
~~~~~~~~~~~~~~~~~~~~~~~
algorithm  n. 算法
~~~~~~~~~~~~~~~~~~~~~~~
accomplish  vt. 完成
~~~~~~~~~~~~~~~~~~~~~~~
scheme n. 方案, 计划,
v. 设计, 体系, 结构,
~~~~~~~~~~~~~~~~~~~~~~~
compute  vt. 计算
~~~~~~~~~~~~~~~~~~~~~~~
code n. 码,密码
vt. 把...编码
~~~~~~~~~~~~~~~~~~~~~~~
halt v 停止
~~~~~~~~~~~~~~~~~~~~~~~
computation n. 计算,计算方法,计算结果
~~~~~~~~~~~~~~~~~~~~~~~
knowledge  n. 知识,了解
~~~~~~~~~~~~~~~~~~~~~~~
declarative adj. 说明的, 陈述的
declarative knowledge 陈述性知识
~~~~~~~~~~~~~~~~~~~~~~~
imperative adj. 命令式的,互动的
imperative knowledge 互动性知识
~~~~~~~~~~~~~~~~~~~~~~~
recipe n. 挂起,暂停
~~~~~~~~~~~~~~~~~~~~~~~
evaluate  vt. 评估,评价
~~~~~~~~~~~~~~~~~~~~~~~
square root 平方根 the square root of a number x
x的平方根
~~~~~~~~~~~~~~~~~~~~~~~
deduce vt. 演绎,推断
~~~~~~~~~~~~~~~~~~~~~~~


Process finished with exit code 0

猜你喜欢

转载自blog.csdn.net/zbrj12345/article/details/80283829