我目前正在考慮一些自動化來讀取網頁數據。那麼是否可以閱讀以下類型的表格以便從網頁中讀取excel:excel的值應該爲name of condion,Operator and Expressions
。是否可以讀取網頁的html表格數據?
編輯
>>> 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
>>>
EDIT2
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
>>>
感謝
看起來你希望我們爲你寫一些代碼。儘管許多用戶願意爲遇險的編碼人員編寫代碼,但他們通常只在海報已嘗試自行解決問題時才提供幫助。證明這一努力的一個好方法是包含迄今爲止編寫的代碼,示例輸入(如果有的話),期望的輸出和實際獲得的輸出(控制檯輸出,堆棧跟蹤,編譯器錯誤 - 無論是適用)。您提供的細節越多,您可能會收到的答案就越多。 –
簡短的回答:肯定有可能,你有什麼嘗試? –
任何人都可以幫助我在這裏開始? – CodeLover