Created
September 11, 2020 15:19
-
-
Save rejsmont/d6980ff8d111d7d2211eaca28fac04d8 to your computer and use it in GitHub Desktop.
Check if the results for ANR grant committee are available
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
import re, requests | |
from urllib.request import urlopen | |
from lxml import etree | |
def committee_available(comm): | |
url = 'https://anr.fr/fr/detail/call/appel-a-projets-generique-2020/' | |
headers = {'Content-Type': 'text/html',} | |
response = requests.get(url, headers=headers) | |
html = response.text | |
htmlparser = etree.HTMLParser() | |
tree = etree.fromstring(html, htmlparser) | |
r = tree.xpath('//section/div/div/ul/li/a[contains(@href,"selection") and contains(text(),"JCJC")]') | |
r[0].xpath('@href') | |
txt = r[0].xpath('text()')[0] | |
resul = re.search('.*?(([0-9]{1,2}-)*[0-9]{1,2}).*', txt) | |
coms = resul.group(1).split('-') | |
return comm in coms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment