Skip to content

Instantly share code, notes, and snippets.

@mattions
Last active December 19, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattions/5916750 to your computer and use it in GitHub Desktop.
Save mattions/5916750 to your computer and use it in GitHub Desktop.
Checking if a sentence goes away from a page.
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