Example #1
0
    def open_splash(self, cache, browser):
        '''Browse to APA splash page for article.'''

        # Get link to abstract from starting page
        abstract_link = cache.init_qhtml(utils.build_query(
            'meta',
            [['name', 'citation_abstract_html_url']]
        )).attr('content')

        # Get APA Accession Number from link
        apa_id_raw = abstract_link.split('journals')[-1].strip('/')
        apa_id = 'AN %s' % (apa_id_raw.replace('/', '-'))

        # Open APA search page
        browser.open('http://www.lib.umich.edu/database/link/27957')
        html, qhtml = browser.get_docs()

        # Hack: Identify search form action from JS
        action_str = qhtml('#SearchButton').attr('data-formsubmit')
        action_dict = json.loads(action_str)
        action_url = urlparse.urljoin(browser.geturl(), action_dict['action'])

        # Submit search form
        browser._b.select_form(nr=0)
        browser._b.form.action = action_url
        browser._b['GuidedSearchFormData[1].SearchTerm'] = apa_id
        browser._b.submit(type='submit')
Example #2
0
    def open_splash(self, cache, browser):
        """Browse to APA splash page for article."""

        # Get link to abstract from starting page
        abstract_link = cache.init_qhtml(utils.build_query("meta", [["name", "citation_abstract_html_url"]])).attr(
            "content"
        )

        # Get APA Accession Number from link
        apa_id_raw = abstract_link.split("journals")[-1].strip("/")
        apa_id = "AN %s" % (apa_id_raw.replace("/", "-"))

        # Open APA search page
        browser.open("http://www.lib.umich.edu/database/link/27957")
        html, qhtml = browser.get_docs()

        # Hack: Identify search form action from JS
        action_str = qhtml("#SearchButton").attr("data-formsubmit")
        action_dict = json.loads(action_str)
        action_url = urlparse.urljoin(browser.geturl(), action_dict["action"])

        # Submit search form
        browser._b.select_form(nr=0)
        browser._b.form.action = action_url
        browser._b["GuidedSearchFormData[1].SearchTerm"] = apa_id
        browser._b.submit(type="submit")
Example #3
0
    def get_link(self, cache, browser):

        tags = cache.init_qhtml(utils.build_query("meta", self._attrs))

        if self._filter:
            tags = tags.filter(self._filter)

        content = tags.attr("content")
        if content:
            return content

        raise NotFoundError("Link not found")
Example #4
0
 def fun(html):
     return bool(PyQuery(html)(utils.build_query(
         'meta', attrs, opers
     )))