1
我試圖從html文本中搜索一個單詞(即。meta),並從該單詞的位置開始打印以下20個字符。Python - 從位置開始打印文本(html)
下面的代碼不返回任何內容:
import os,sys,urllib.request
url = "http://www.google.com/"
req = urllib.request.Request(url)
response = urllib.request.urlopen(req)
html = response.read()
html2 = html.decode("windows-1252")
b2='meta'
position=html2.index(b2)
if b2 in html2:
print(html2[position:20])
謝謝!沒有看到它 – user2169081 2013-03-14 09:43:38
@ user2169081歡迎您))) – 2013-03-14 09:44:45