#!/usr/bin/env python
#-*- coding:utf-8 -*-
import urllib
import urllib2
#有一颗耐不住寂寞的心,决定再试试找找其他(除了POST方式)跟有道干起来的爬取方式
#功夫不负有心人 url="http://dict.youdao.com/search?q=python&keyfrom=fanyi.smartResult"
queryword = raw_input("Enter word:")
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
}
##url="http://dict.youdao.com/search?q=python&keyfrom=fanyi.smartResult"
url = "http://dict.youdao.com/search?q="+queryword+"&keyfrom=fanyi.smartResult"
##response = urllib2.Request(url)
html = urllib.urlopen(url).read()
print html
时间: 2024-10-10 06:30:03