I am trying to do scraping in Python.
Then, I want to scrape a stock-info website. But I failed, I don’t know why.
JavaScript
x
7
1
import urllib
2
3
# wallstreetcn info page
4
url_src = 'view-source:https://wallstreetcn.com/live/global?from=navbar'
5
6
url_content = urllib.request.urlopen(url_src)
7
It gives the error below:
JavaScript
1
2
1
URLError: urlopen error unknown url type: view-source
2
But when I used Chrome I can view the source code by right-click.
Advertisement
Answer
Try removing view-source:
from your url_src
, in essence:
JavaScript
1
2
1
url_src = 'https://wallstreetcn.com/live/global?from=navbar'
2
I think view-source:
is Chrome specific (so Chrome knows to show you source rather than the webpage).