Ejemplo n.º 1
0
 def test_parse_images(self):
     html = """
     <li>
         <div>
             <a href="http://www.google.com/url?q=http://this.is.the.url/">
                 <img style="margin:3px 0;margin-right:6px;padding:0" height="90"
                     src="https://this.is.the.image/image.jpg" width="60" align="middle" alt="" border="0">
             </a>
         </div>
     </li>
     """
     dom = lxml.html.fromstring(html)
     results = google.parse_images(dom, 'www.google.com')
     self.assertEqual(type(results), list)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0]['url'], 'http://this.is.the.url/')
     self.assertEqual(results[0]['title'], '')
     self.assertEqual(results[0]['content'], '')
     self.assertEqual(results[0]['img_src'], 'https://this.is.the.image/image.jpg')
Ejemplo n.º 2
0
 def test_parse_images(self):
     html = """
     <li>
         <div>
             <a href="http://www.google.com/url?q=http://this.is.the.url/">
                 <img style="margin:3px 0;margin-right:6px;padding:0" height="90"
                     src="https://this.is.the.image/image.jpg" width="60" align="middle" alt="" border="0">
             </a>
         </div>
     </li>
     """
     dom = lxml.html.fromstring(html)
     results = google.parse_images(dom, 'www.google.com')
     self.assertEqual(type(results), list)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0]['url'], 'http://this.is.the.url/')
     self.assertEqual(results[0]['title'], '')
     self.assertEqual(results[0]['content'], '')
     self.assertEqual(results[0]['img_src'], 'https://this.is.the.image/image.jpg')