我正在爲其當天的形象刮http://apod.nasa.gov/。到目前爲止,我已經能夠返回我認爲是圖像源標籤的內容。使用urllib2來掃描圖像的Python?
#!/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從這裏?
那麼,談論過度思考吧,:|感謝您的幫助,gahooa – tijko 2012-08-10 04:09:56