opening a url with urllib in python 3

后端 未结 5 654
我在风中等你
我在风中等你 2020-12-24 07:27

i\'m trying to open the URL of this API from the sunlight foundation and return the data from the page in json. this is the code Ive produced, minus the parenthesis around m

5条回答
  •  眼角桃花
    2020-12-24 07:43

    from urllib.request import urlopen
    from bs4 import BeautifulSoup
    
    wiki = "https://en.wikipedia.org/wiki/List_of_state_and_union_territory_capitals_in_India"
    
    page = urlopen(wiki)
    soup =  BeautifulSoup(page, "html.parser" ).encode('UTF-8')
    
    print (soup)
    

提交回复
热议问题