Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Fri Feb 24 11:28:32 2017
- @author: borsha
- """
- import requests
- from bs4 import BeautifulSoup
- def get_code(url):
- req=requests.get(url)
- code=req.text
- return code
- def check(text):
- return type(text)!= type(None) and text.find("\n")==-1
- def bs4_get(content,func):
- soup=BeautifulSoup(content,"html.parser")
- get_all=soup.find_all(string=func)
- return get_all
- def atcoder():
- url="https://atcoder.jp/"
- texts=get_code(url)
- all_text=bs4_get(texts,check)
- start=all_text.index("Upcoming Contests")+2
- end=all_text.index("Recent Contests")
- all_text=all_text[start:end]
- file=open("upcoming contests.txt",'w')
- for i in all_text:
- file.write(i)
- file.write("\n")
- file.close()
- atcoder()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement