I am trying to determine the best way to save an unknown string on a web page that relates to a specific tag, using Python. E.g.
<div class="pictures">
<img src="http://some.unknownaddress.com/random_image.jpg" alt="" class="image" height="123" width="123">
What I wish to pull out is the images URL address and use it to download the image. The class “pictures” is unique to the page so I gather I can use that as a reference point to grab the URL, but what I’m not sure of is how to write the code to specifically select what even URL is inbetween the ” ” following that “pictures” class.
I am thinking down the line of using re, but have no idea how to concoct a string to make it select that particualar string. Should I be using Beautiful Soup to help?
Any help would be much appreciated.
Thanks,
Dog.
This is messy but would get the job done. Obviously it’d be better to break this down into functions, etc. to make it smoother. Note that I haven’t tested this script specifically, but I have written other scripts in this ilk to do similar things (break down html, add stuff in, and paste it back together, for instance). It’s a bit tedious, and not pretty, but again…it’ll work.