Issue
I try get data from table in my Django project from local server
But have a problem after run programm with pandas code:
c:\Users\kadzutokun\Desktop\tables.py:3: FutureWarning: Passing literal html to 'read_html' is deprecated and will be removed in a future version. To read from a literal string, wrap it in a 'StringIO' object.
tables = pd.read_html(
C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py:666: MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
soup = BeautifulSoup(udoc, features="html5lib", from_encoding=from_encoding)
Traceback (most recent call last):
tables = pd.read_html(
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 1245, in read_html
return _parse(
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 1008, in _parse
raise retained
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 988, in _parse
tables = p.parse_tables()
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 248, in parse_tables
tables = self._parse_tables(self._build_doc(), self.match, self.attrs)
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 603, in _parse_tables
raise ValueError("No tables found")
ValueError: No tables found
PS C:\Users\kadzutokun> & C:/Users/kadzutokun/AppData/Local/Programs/Python/Python310/python.exe c:/Users/kadzutokun/Desktop/tables.py
c:\Users\kadzutokun\Desktop\tables.py:3: FutureWarning: Passing literal html to 'read_html' is deprecated and will be removed in a future version. To read from a literal string, wrap it in a 'StringIO' object.
tables = pd.read_html(
C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py:666: MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
soup = BeautifulSoup(udoc, features="html5lib", from_encoding=from_encoding)
Traceback (most recent call last):
File "c:\Users\kadzutokun\Desktop\tables.py", line 3, in <module>
tables = pd.read_html(
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 1245, in read_html
return _parse(
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 1008, in _parse
raise retained
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 248, in parse_tables
tables = self._parse_tables(self._build_doc(), self.match, self.attrs)
File "C:\Users\kadzutokun\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\html.py", line 603, in _parse_tables
raise ValueError("No tables found")
ValueError: No tables found
pandas code
import pandas as pd
tables = pd.read_html(
'127.0.0.1:8000/shop/',)
print(len(tables))
127.0.0.1:8000/shop/
Please help resolve
Solution
@AbdulNiyasPM's intuition is right, try with a protocol. If you pass a string without any protocol, Pandas assumes that you want to parse the string as HTML:
tables = pd.read_html('http://127.0.0.1:8000/shop/')
Documentation of pd.read_html:
io (str, path object, or file-like object)
String, path object (implementing os.PathLike[str]), or file-like object implementing a string read() function. The string can represent a URL or the HTML itself. Note that lxml only accepts the http, ftp and file url protocols. If you have a URL that starts with 'https' you might try removing the 's'.
Answered By - Corralien
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.