繁体   English   中英

从网站读取数据并使用python正则表达式

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM