2015-03-12 1 views
0

Я хотел бы получить имена всех авторов от Google Scholar. Мой базовый url - http://scholar.google.pl/citations?view_op=search_authors&hl=pl&mauthors=label:security Так что в основном, я ищу авторов, которые что-то писали о безопасности.BeautifulSoup, Google Scholar, имена авторов, аффилиации и цитаты тоже

Я написал несколько сценарий Python с использованием BeautifulSoup, но (не знаю почему) сценарий показывает пустые списки, как он не нашел никаких данных элементов (однако, когда я смотрю в исходный код страницы, я вижу <div class="gsc_1usr_text"> элементы) ,

Heres мой код:

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 
from bs4 import BeautifulSoup 
url = "http://scholar.google.pl/citations?view_op=search_authors&hl=pl&mauthors=label:security" 
content = urllib2.urlopen(url).read() 
soup = BeautifulSoup(content) 
mydivs = soup.findAll("div", { "class" : "gsc_1usr_text" }) 
print mydivs 

и выход [], print "LEN = " + str(len(mydivs)) показывает мне 0.

Im используя Python 2.7.3 на Linux Mint 13.

+0

это работает для меня .. –

+0

@AvinashRaj: Интересно! Не могли бы вы показать мне свой результат? У меня есть только пустые списки, не знаю почему :( – mazix

ответ

1

Ваш код работает для меня.

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 
import urllib2 
from bs4 import BeautifulSoup 
url = "http://scholar.google.pl/citations?view_op=search_authors&hl=pl&mauthors=label:security" 
content = urllib2.urlopen(url).read() 
soup = BeautifulSoup(content) 
mydivs = soup.findAll("div", { "class" : "gsc_1usr_text" }) 
print mydivs 

Выход:

[<div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=n-Oret4AAAAJ&amp;hl=pl&amp;oe=Latin2">Adrian Perrig</a></h3><div class="gsc_1usr_aff">Professor of Computer Science at ETH Zürich, Adjunct Professor of ECE and EPP at CMU</div><div class="gsc_1usr_eml">Zweryfikowany adres z inf.ethz.ch</div><div class="gsc_1usr_emlb">@inf.ethz.ch</div><div class="gsc_1usr_cby">Cytowane przez 40938</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">Security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:networking">Networking</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:operating_systems">Operating Systems</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:computer_security">Computer Security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:internet_security">Internet Security</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=HvwPRJ0AAAAJ&amp;hl=pl&amp;oe=Latin2">Vern Paxson</a></h3><div class="gsc_1usr_aff">Professor, EECS, University of California, Berkeley</div><div class="gsc_1usr_eml">Zweryfikowany adres z berkeley.edu</div><div class="gsc_1usr_emlb">@berkeley.edu</div><div class="gsc_1usr_cby">Cytowane przez 39914</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:networking">Networking</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">Security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:measurement">Measurement</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=2pW1g5IAAAAJ&amp;hl=pl&amp;oe=Latin2">Mihir Bellare</a></h3><div class="gsc_1usr_aff">Professor, Department of Computer Science and Engineering, UCSD</div><div class="gsc_1usr_eml">Zweryfikowany adres z eng.ucsd.edu</div><div class="gsc_1usr_emlb">@eng.ucsd.edu</div><div class="gsc_1usr_cby">Cytowane przez 35459</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:cryptography">Cryptography</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">Security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:complexity_theory">Complexity Theory</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=FCsdj0YAAAAJ&amp;hl=pl&amp;oe=Latin2">Wenyuan Xu</a></h3><div class="gsc_1usr_aff">Assistant Profess of Department of Computer Science and Engineering, University of South …</div><div class="gsc_1usr_cby">Cytowane przez 32521</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:wireless_networks">Wireless Networks</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">Security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:jamming_defenses">jamming defenses</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:dependable_systems">dependable systems</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=vWTI60AAAAAJ&amp;hl=pl&amp;oe=Latin2">Martin Abadi</a></h3><div class="gsc_1usr_aff">Principal Scientist, Google, and Professor Emeritus, UC Santa Cruz</div><div class="gsc_1usr_eml">Zweryfikowany adres z cs.ucsc.edu</div><div class="gsc_1usr_emlb">@cs.ucsc.edu</div><div class="gsc_1usr_cby">Cytowane przez 29938</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:programming_languages_and_systems">programming languages and systems</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:specification_and_verification">specification and verification</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=lOZ1vHIAAAAJ&amp;hl=pl&amp;oe=Latin2">Sushil Jajodia</a></h3><div class="gsc_1usr_aff">University Professor, BDM International Professor, and Director, Center for Secure …</div><div class="gsc_1usr_eml">Zweryfikowany adres z gmu.edu</div><div class="gsc_1usr_emlb">@gmu.edu</div><div class="gsc_1usr_cby">Cytowane przez 29705</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:privacy">privacy</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:database">database</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:databases">databases</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:distributed_systems">distributed systems</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=Z_enRVYAAAAJ&amp;hl=pl&amp;oe=Latin2">Xiaolan Zhang</a></h3><div class="gsc_1usr_aff">IBM</div><div class="gsc_1usr_eml">Zweryfikowany adres z us.ibm.com</div><div class="gsc_1usr_emlb">@us.ibm.com</div><div class="gsc_1usr_cby">Cytowane przez 27321</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:virtualization">Virtualization</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">Security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:systems">Systems</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=W7YBLlEAAAAJ&amp;hl=pl&amp;oe=Latin2">Jean-Pierre Hubaux</a></h3><div class="gsc_1usr_aff">Professor, EPFL</div><div class="gsc_1usr_eml">Zweryfikowany adres z epfl.ch</div><div class="gsc_1usr_emlb">@epfl.ch</div><div class="gsc_1usr_cby">Cytowane przez 24738</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:privacy">Privacy</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">Security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:networking">Networking</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=WgyDcoUAAAAJ&amp;hl=pl&amp;oe=Latin2">Ross Anderson</a></h3><div class="gsc_1usr_aff">University of Cambridge</div><div class="gsc_1usr_eml">Zweryfikowany adres z cl.cam.ac.uk</div><div class="gsc_1usr_emlb">@cl.cam.ac.uk</div><div class="gsc_1usr_cby">Cytowane przez 24445</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">Security</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:cryptology">cryptology</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:dependability">dependability</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:technology_policy">technology policy</a> </div></div>, <div class="gsc_1usr_text"><h3 class="gsc_1usr_name"><a href="/citations?user=lsKlsJ8AAAAJ&amp;hl=pl&amp;oe=Latin2">Heejo Lee</a></h3><div class="gsc_1usr_aff">Professor of Computer Science, Korea University</div><div class="gsc_1usr_eml">Zweryfikowany adres z korea.ac.kr</div><div class="gsc_1usr_emlb">@korea.ac.kr</div><div class="gsc_1usr_cby">Cytowane przez 23596</div><div class="gsc_1usr_int"><a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:network">network</a> <a class="gsc_co_int" href="/citations?view_op=search_authors&amp;hl=pl&amp;oe=Latin2&amp;mauthors=label:security">security</a> </div></div>] 
+0

Как это возможно? У вас есть все авторы, которые мне нужны! Какая версия ОС и Python вы использовали? В любом случае, что мне делать, чтобы получить тот же результат? (I означает, что любой результат, теперь он печатает только пустые списки ...) – mazix

+0

ОС: Ubuntu 14.04, версия python 2.7, потому что 'print mydivs' не будет работать в 3+ –

+0

Итак, как я могу это сделать? Даже для e in mydivs : print e' не работает, он не печатает divs, у меня есть Python 2.7.3 – mazix

Смежные вопросы