Last active
December 19, 2015 07:09
-
-
Save mattions/5916750 to your computer and use it in GitHub Desktop.
Checking if a sentence goes away from a page.
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 requests | |
import time | |
from datetime import datetime | |
from bs4 import BeautifulSoup | |
URL="http://www.plosone.org/search/advanced?pageSize=12&sort=&queryField=author&queryTerm=&unformattedQuery=author%3A%22Michele+Mattioni%22&journalOpt=some&filterJournals=PLoSONE&subjectCatOpt=all&filterArticleTypeOpt=all" | |
SENTENCE_WHICH_SHOULD_CHANGE="There were no results" | |
article_out = False | |
while not article_out: | |
request = requests.get(URL) | |
soup = BeautifulSoup(request.text) | |
if SENTENCE_WHICH_SHOULD_CHANGE in soup.get_text(): | |
print "{0} Still no result".format(datetime.now()) | |
time.sleep(30) | |
else: | |
print "{0} Results found! Article should be out!".format(datetime.now()) | |
print "Check the URL: {0}".format(URL) | |
article_out = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment