Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got scraper working #3

Open
Kamik423 opened this issue Jan 4, 2019 · 1 comment
Open

Got scraper working #3

Kamik423 opened this issue Jan 4, 2019 · 1 comment

Comments

@Kamik423
Copy link

Kamik423 commented Jan 4, 2019

No time to make a separate pull request for this, but I got the scraper working:

import ui
import time

class Scraper (object):
    def __init__(self, url, js = 'document.documentElement.outerHTML'):
        self.wv = ui.WebView()
        self.wv.delegate = self
        self.wv.load_url(url)
        self.js = js
        self.response = None
    
    def webview_did_finish_load(self, webview):
        self.response = webview.eval_js(self.js)
    
    @property
    def value(self):
        while self.response is None:
            time.sleep(0.1)
        return self.response

def main():
    v = Scraper(url, 'document.documentElement.outerHTML;').value

It is a bit of a hack and probably not all that efficient, but it works perfectly

@tdamdouni
Copy link
Owner

Hi, thanks I will check and update the script. Sometimes it takes time to answer and merge pull requests but thanks for keeping the repo up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants