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

Bibtex not working #102

Open
rafed opened this issue Jan 4, 2018 · 9 comments
Open

Bibtex not working #102

rafed opened this issue Jan 4, 2018 · 9 comments

Comments

@rafed
Copy link

rafed commented Jan 4, 2018

Is the extracting bibtex working? I've been trying for a few days and it doesnt seem to work. Any suggestions?

@soreana
Copy link

soreana commented Feb 9, 2018

same issue

1 similar comment
@MooersLab
Copy link

same issue

@rafed rafed changed the title Bibtext not working Bibtex not working Feb 13, 2018
@EthanS94
Copy link

What worked for me was changing line 485 from:

self.article['url_citation'] = self._path2url(tag.get('href'))

to:

self.article['url_citation'] = tag.get('href')

@MooersLab
Copy link

MooersLab commented Feb 14, 2018 via email

@EthanS94
Copy link

Sorry, this went along with a change from @portalgun's comment on issue #101. I also changed line 985.

tag = soup.find(name='form', attrs={'id': 'gs_settings_form'})
to
tag = soup.find(name='form', attrs={'id': 'gs_bdy_frm'})

Try adding this change along with mine and see if it works.

@soreana
Copy link

soreana commented Feb 14, 2018

That's working 👍
Thanks :)

@MooersLab
Copy link

MooersLab commented Feb 14, 2018 via email

agasy18 added a commit to agasy18/scholar.py that referenced this issue Jun 24, 2018
@mcnesium
Copy link

so I applied the suggested patches like this:

$ git diff
diff --git a/scholar.py b/scholar.py
index 13ccd43..2133d67 100755
--- a/scholar.py
+++ b/scholar.py
@@ -482,7 +482,7 @@ class ScholarArticleParser(object):
-        self.article['url_citation'] = self._path2url(tag.get('href'))
+        self.article['url_citation'] = tag.get('href')

@@ -982,7 +982,7 @@ class ScholarQuerier(object):
-        tag = soup.find(name='form', attrs={'id': 'gs_settings_form'})
+        tag = soup.find(name='form', attrs={'id': 'gs_bdy_frm'})

but trying to run the example command throws the following errors:

$ python scholar.py -c 1 --author "albert einstein" --phrase "quantum theory" --citation bt
Traceback (most recent call last):
File "scholar.py", line 1310, in <module>
    sys.exit(main())
File "scholar.py", line 1300, in main
    citation_export(querier)
File "scholar.py", line 1145, in citation_export
    print(art.as_citation() + '\n')
TypeError: can't concat str to bytes
$ 

So I removed the + '\n' from line 1145:

@@ -1142,7 +1142,7 @@ def citation_export(querier):
-        print(art.as_citation() + '\n')
+        print(art.as_citation())

then the Google API blocked me, but I saw this work once…

rreece added a commit to rreece/scholar.py that referenced this issue Dec 4, 2018
rreece added a commit to rreece/markdown2bib that referenced this issue Dec 20, 2018
johnrsibert added a commit to johnrsibert/scholar.py that referenced this issue Mar 5, 2019
@SvennoNito
Copy link

SvennoNito commented Jan 18, 2020

I needed to apply both changes from issue #101,

tag = soup.find(name='form', attrs={'id': 'gs_settings_form'})
to
tag = soup.find(name='form', attrs={'id': 'gs_bdy_frm'})

and

print(art.as_citation() + '\n')
to
art.as_citation().decode("utf-8") + "\n"

Together with the fix from @EthanS94 it finally worked for me to use the --citation bt option :-)
Even though the output is not as nicely formatted as the example in the README.

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

6 participants