Answer the question
In order to leave comments, you need to log in
BeautifulSoup not working?
Actually, I want to get the address of the picture. But the problem is that nothing works. Doesn't even show the document.
import urllib.request as urllib2
from bs4 import BeautifulSoup
page = urllib2.urlopen("http://www.vokrugsveta.ru/vs/").read()
soup = BeautifulSoup(page)
print(soup.find("img", class='framepic'))
Answer the question
In order to leave comments, you need to log in
import urllib.request as urllib2
from bs4 import BeautifulSoup
page = urllib2.urlopen("http://www.vokrugsveta.ru/vs/").read()
soup = BeautifulSoup(page)
imglink = soup.find("img", {"class": "framepic"}).get('src')
print (imglink)
class - a reserved word of the language in Bs4 instead of it in the parameters, you can useclass_
# Варианты:
print(soup.find("img", class_='framepic'))
print(soup.find("img", {'class':'framepic'}))
print(soup.find("img", 'framepic'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question