python webkit 异步抓取页面数据

http://blog.youkuaiyun.com/cabing2005/article/details/9764379

http://nightly.webkit.org/


[python]  view plain copy
  1. #!/usr/bin/python  
  2. from ghost import Ghost  
  3.   
  4.   
  5. class FetcherCartoon:  
[python]  view plain copy
  1. def getCartoonUrl(self, url):  
  2.       
  3.     if url is None:  
  4.         return false  
  5.     #todo many decide about url  
  6.       
  7.     ghost = Ghost()  
  8.     #open webkit  
  9.     ghost.open(url)  
  10.     #exceute javascript and get what you want   
  11.     result, resources = ghost.evaluate("document.getElementById('cp_image').getAttribute('src');")  
  12.     del resources  
  13.     return result  
[python]  view plain copy
  1. if __name__ == "__main__":  
  2.     url = 'http://www.dm5.com/m136836-p3/'  
  3.     result = None  
  4.     fetcher = FetcherCartoon()  
  5.   
  6.   
  7.     result = fetcher.getCartoonUrl(url)  
  8.     print result  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值