我正在开展一个项目,我希望从Google学术搜索中获取数据。我想刮掉所有在类别中标记的作者(例如Anaphylaxis),并将其引用次数,h-index和i-10索引存储在CSV文件中。但是,鉴于Google Scholar没有API,我不确定如何做到这一点。我知道我可以使用像美丽汤这样的刮刀,但我不确定如何在不被阻挡的情况下刮取数据。
所以,我的问题是如何使用bs4将所有被标记为Anaphylaxis的作者以及每个作者的引文,h-index和i-10索引存储在csv文件中。
答案 0 :(得分:0)
所有刮刀正在解析一些HTML页面。在搜索时,作者在div中使用class =“gs_a”如果您使用Beautiful Soup并查找此类,您将能够找到所有作者。您可以通过更新网址逐页浏览。
https://scholar.google.ca/scholar?start=20&q=polymer&hl=en&as_sdt=0,5 至 https://scholar.google.ca/scholar?start=30&q=polymer&hl=en&as_sdt=0,5
即。开始= 30然后40等。
然后,您可以在gs_a类标记中的链接路径上循环作者名称。
请告诉我这是否有帮助!
-Kyle
答案 1 :(得分:0)
要获取任何“类别”(标签:查询)或“名称”的所有配置文件,您可以使用第三方解决方案,如 SerpApi。这是一个免费试用的付费 API。
示例 Python 代码(也可在其他库中使用):
from serpapi import GoogleSearch
params = {
"api_key": "SECRET_API_KEY",
"engine": "google_scholar_profiles",
"q": "Coffee",
"hl": "en",
"mauthors": "label:anaphylaxis"
}
search = GoogleSearch(params)
results = search.get_dict()
示例 JSON 输出:
"profiles": [
{
"name": "Jerrold H Levy",
"link": "https://scholar.google.com/citations?hl=en&user=qnH5V28AAAAJ",
"serpapi_link": "https://serpapi.com/search.json?author_id=qnH5V28AAAAJ&engine=google_scholar_author&hl=en",
"author_id": "qnH5V28AAAAJ",
"affiliations": "Professor of Anesthesiology and Surgery (Cardiothoracic)",
"email": "Verified email at duke.edu",
"cited_by": 80353,
"interests": [
{
"title": "bleeding",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Ableeding",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:bleeding"
},
{
"title": "anaphylaxis",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Aanaphylaxis",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:anaphylaxis"
},
{
"title": "anticoagulation",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Aanticoagulation",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:anticoagulation"
},
{
"title": "shock",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Ashock",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:shock"
}
],
"thumbnail": "https://scholar.googleusercontent.com/citations?view_op=small_photo&user=qnH5V28AAAAJ&citpid=2"
},
...
}
您可以查看documentation了解更多详情。
免责声明:我在 SerpApi 工作。