Last active
October 8, 2020 02:56
-
-
Save alcantarar/08dadebd0eb533a5f221a4b0200651df to your computer and use it in GitHub Desktop.
Get full-text links from pubmed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Untitled0.ipynb", | |
"provenance": [], | |
"authorship_tag": "ABX9TyPptTuEv4FXrw66ID9t6Hi2", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/alcantarar/08dadebd0eb533a5f221a4b0200651df/untitled0.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "woyaCZn_Wmy9" | |
}, | |
"source": [ | |
"from bs4 import BeautifulSoup\n", | |
"import requests\n" | |
], | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "X4gyG17EXnyp", | |
"outputId": "a3de4e23-dc3c-4494-f92f-9c5cabe92dd0", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
} | |
}, | |
"source": [ | |
"page = requests.get('https://pubmed.ncbi.nlm.nih.gov/28672004/')\n", | |
"soup = BeautifulSoup(page.content, 'html.parser')\n", | |
"full_texts = soup.find('div', class_='full-text-links-list')\n", | |
"full_texts.find('a')['href']" | |
], | |
"execution_count": 126, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'https://dx.plos.org/10.1371/journal.pone.0180575'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 126 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment