I am new to web scraping using bs4 and I want to get the image of a protein from the Protein Data Bank (PDB):
https://www.rcsb.org/structure/1A69
When I inspect the HTML with Chrome Inspector I see that the image is sourced through a http link that I can easily go to and save the image from.
<img class="img-responsive center-block mainImage"
src="https://cdn.rcsb.org/images/rutgers/a6/1a69/1a69.pdb1-500.jpg">
However, when I run my script to extract the src, I only get it as base64.
data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=
Am I doing something wrong? What's happening? Is there a way to get the http link back from base64?
My code:
from bs4 import BeautifulSoup as bs
from urllib.request import urlopen
url = "https://www.rcsb.org/structure/1A69"
resp = urlopen(url)
page = bs(resp,"html.parser")
for img in page.findAll('img',{'class':'img-responsive'}):
src = img['src']
print(src)