[英]Reading Data from a website and using python regex
我正在嘗試從站點獲取信息,一行一行地讀取信息,只采用以兩位數,分號,兩位數字,分號和另外兩位數字(即00:00:00)開頭的行。 匹配項將導出到另一個文件。
我在正則表達式中遇到了分號的語法錯誤。
#!/usr/bin/python
import urllib2
import re
#imported urllib to collect the data. imported re for regular expressions to test format.
#creating our output file
f=open("output.txt", "r+")
#opening a file like object using urllib
webpage= urllib2.open("https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf")
#string used to store the output
str=""
#string used to store current line
temp=""
#add while loop to read in that data. line by line.
temp=webpage.readline()
if temp.re.search([0-9][0-9]:[0-9][0-9]:[0-9][0-9]):
str.concat(temp)
temp=""
您正在使用原始代碼搜索,請嘗試輸入字符串
if temp.re.search("[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.