我目前正在考虑一些自动化来读取网页数据。那么是否可以从网页中读取下面这样的表格以读入 excel:excel 的值应为name of condion,Operator and Expressions
.
编辑
>>> from urllib import urlopen
>>> from bs4 import BeautifulSoup
>>> source = BeautifulSoup(urlopen(url))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'url' is not defined
>>> source = BeautifulSoup(urlopen(https://demo.aravo.com))
File "<stdin>", line 1
source = BeautifulSoup(urlopen(https://demo.aravo.com))
^
SyntaxError: invalid syntax
>>> from urllib import urlopen
>>> from bs4 import BeautifulSoup
>>> source = BeautifulSoup(urlopen(https://demo.aravo.com/))
File "<stdin>", line 1
source = BeautifulSoup(urlopen(https://demo.aravo.com/))
^
SyntaxError: invalid syntax
>>> source = BeautifulSoup(urlopen(demo.aravo.com/))
File "<stdin>", line 1
source = BeautifulSoup(urlopen(demo.aravo.com/))
^
SyntaxError: invalid syntax
>>> source = BeautifulSoup(urlopen(demo.aravo.com))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'demo' is not defined
>>>
编辑2
C:\Users>cd..
C:\>cd cd C:\Python27\selenv\Scripts
The filename, directory name, or volume label syntax is incorrect.
C:\>cd C:\Python27\selenv\Scripts
C:\Python27\selenv\Scripts>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib import urlopen
>>> from bs4 import BeautifulSoup
>>> source = BeautifulSoup(urlopen("https://demo.aravo.com/"))
>>> tables = source.findAll('td')
>>> import csv
>>> writer = csv.writer(open('filename.csv','w'))
>>> writer.writerow(rows)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'rows' is not defined
>>>
谢谢