-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsscrape.py
31 lines (25 loc) · 865 Bytes
/
jsscrape.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from lxml import html
#Take this class for granted.Just use result of rendering.
class Render(QWebPage):
def __init__(self, url):
self.app = QApplication(sys.argv)
QWebPage.__init__(self)
self.loadFinished.connect(self._loadFinished)
self.mainFrame().load(QUrl(url))
self.app.exec_()
def _loadFinished(self, result):
self.frame = self.mainFrame()
self.app.quit()
url = 'https://pokevision.com/#/@51.07005488929763,-1.3184666633605957'
r = Render(url)
result = r.frame.toHtml()
#print(result.encode("utf-8"))
tree = html.fromstring(result.encode("utf-8"))
#Finding all anchor tags in response
pokemon = tree.xpath('//div[@class="leaflet-marker-pane"]/div/img/@src')
print(len(pokemon))
print(pokemon)