ImportError: No module named BeautifulSoup

前端 未结 8 1173
無奈伤痛
無奈伤痛 2020-11-28 23:50

I have installed BeautifulSoup using easy_install and trying to run following script

from BeautifulSoup import BeautifulSoup
import re

doc = [\'         


        
8条回答
  •  死守一世寂寞
    2020-11-29 00:29

    Try This, Mine worked this way. To get any data of tag just replace the "a" with the tag you want.

    from bs4 import BeautifulSoup as bs
    import urllib
    
    url="http://currentaffairs.gktoday.in/month/current-affairs-january-2015"
    
    soup = bs(urllib.urlopen(url))
    for link in soup.findAll('a'):
            print link.string
    

提交回复
热议问题