我正在抓取http://apod.nasa.gov/以获取其当天的形象。到目前为止,我已经能够返回我认为是图像源标签的内容。
#!/usr/bin/env python
from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
class Apod:
def apod_wallpaper(self):
self.soup = BeautifulSoup(urlopen('http://apod.nasa.gov/').read())
self.pic = self.soup.find('img')
return self.pic
print Apod().apod_wallpaper()
>>> ./apod.py
>>> <img src="image/1208/Ma2011-2Tezel900.jpg" name="imagename1" alt="See Explanation.
Moving the cursor over the image will bring up an annotated version.
Clicking on the image will bring up the highest resolution version
available." />
我不确定如何从这里下载实际的.jpg?