from bs4 import BeautifulSoup
import urllib3
import sqlite3
import re

def pull_facts():
	http = urllib3.PoolManager()

	url = "https://en.wikipedia.org/wiki/Main_Page"
	response = http.request('GET', url)
	soup = BeautifulSoup(response.data, "html.parser")

	dyk = soup.find(id="mp-dyk")

	db = sqlite3.connect('facts.db')

	for li in dyk.ul.find_all("li"):
		title = li.text.replace("?","").replace("...","TIL")
		title = re.sub("[\(\[].*?[\)\]]", "", title).replace("  "," ")
		link = "https://en.wikipedia.org"+li.b.a.get("href")
		db.cursor().execute("INSERT INTO facts(title,link) VALUES(?,?)",[title,link])
		db.commit()
		print(title)

pull_facts()
34a22f2bf6bc86be04b31a13f505ab93316418e4
<mask token>

<mask token>


def pull_facts():
    http = urllib3.PoolManager()
    url = 'https://en.wikipedia.org/wiki/Main_Page'
    response = http.request('GET', url)
    soup = BeautifulSoup(response.data, 'html.parser')
    dyk = soup.find(id='mp-dyk')
    db = sqlite3.connect('facts.db')
    for li in dyk.ul.find_all('li'):
        title = li.text.replace('?', '').replace('...', 'TIL')
        title = re.sub('[\\(\\[].*?[\\)\\]]', '', title).replace('  ', ' ')
        link = 'https://en.wikipedia.org' + li.b.a.get('href')
        db.cursor().execute('INSERT INTO facts(title,link) VALUES(?,?)', [
            title, link])
        db.commit()
        print(title)


<mask token>

<mask token>


def pull_facts():
    http = urllib3.PoolManager()
    url = 'https://en.wikipedia.org/wiki/Main_Page'
    response = http.request('GET', url)
    soup = BeautifulSoup(response.data, 'html.parser')
    dyk = soup.find(id='mp-dyk')
    db = sqlite3.connect('facts.db')
    for li in dyk.ul.find_all('li'):
        title = li.text.replace('?', '').replace('...', 'TIL')
        title = re.sub('[\\(\\[].*?[\\)\\]]', '', title).replace('  ', ' ')
        link = 'https://en.wikipedia.org' + li.b.a.get('href')
        db.cursor().execute('INSERT INTO facts(title,link) VALUES(?,?)', [
            title, link])
        db.commit()
        print(title)


pull_facts()

from bs4 import BeautifulSoup
import urllib3
import sqlite3
import re


def pull_facts():
    http = urllib3.PoolManager()
    url = 'https://en.wikipedia.org/wiki/Main_Page'
    response = http.request('GET', url)
    soup = BeautifulSoup(response.data, 'html.parser')
    dyk = soup.find(id='mp-dyk')
    db = sqlite3.connect('facts.db')
    for li in dyk.ul.find_all('li'):
        title = li.text.replace('?', '').replace('...', 'TIL')
        title = re.sub('[\\(\\[].*?[\\)\\]]', '', title).replace('  ', ' ')
        link = 'https://en.wikipedia.org' + li.b.a.get('href')
        db.cursor().execute('INSERT INTO facts(title,link) VALUES(?,?)', [
            title, link])
        db.commit()
        print(title)


pull_facts()

from bs4 import BeautifulSoup
import urllib3
import sqlite3
import re

def pull_facts():
	http = urllib3.PoolManager()

	url = "https://en.wikipedia.org/wiki/Main_Page"
	response = http.request('GET', url)
	soup = BeautifulSoup(response.data, "html.parser")

	dyk = soup.find(id="mp-dyk")

	db = sqlite3.connect('facts.db')

	for li in dyk.ul.find_all("li"):
		title = li.text.replace("?","").replace("...","TIL")
		title = re.sub("[\(\[].*?[\)\]]", "", title).replace("  "," ")
		link = "https://en.wikipedia.org"+li.b.a.get("href")
		db.cursor().execute("INSERT INTO facts(title,link) VALUES(?,?)",[title,link])
		db.commit()
		print(title)

pull_facts()