标签:爬虫入门
#!/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
本文出自 “phize” 博客,请务必保留此出处http://12756301.blog.51cto.com/12746301/1970089
标签:爬虫入门
原文地址:http://12756301.blog.51cto.com/12746301/1970089