如何用python写爬虫

2024-10-31 13:27:34

、python写爬虫很简单;给你个简单的例子:这里def 是用来定义函数用的,urllib.urlopen 是获取链接内容的方法;然后你还要通过正则匹配来获取在这个页面你所需要的东西;就这么简单!def getHtml(url): page = urllib.urlopen(url) html = page.read() return htmlhtml = getHtml("http://tieba.baidu.com/p/2738151262")print html

猜你喜欢