Code an das neue html angepasst
This commit is contained in:
parent
0ff252eda8
commit
bdee140a94
1 changed files with 9 additions and 8 deletions
|
|
@ -12,28 +12,29 @@ try:
|
||||||
cursor.execute("""CREATE TABLE Filosofie (
|
cursor.execute("""CREATE TABLE Filosofie (
|
||||||
Nr INTEGER, Filosofie TEXT)""")
|
Nr INTEGER, Filosofie TEXT)""")
|
||||||
except:
|
except:
|
||||||
|
print('Error')
|
||||||
None
|
None
|
||||||
sql = "SELECT * FROM Filosofie ORDER BY Nr DESC"
|
sql = "SELECT * FROM Filosofie ORDER BY Nr DESC"
|
||||||
resp = cursor.execute(sql)
|
resp = cursor.execute(sql)
|
||||||
resp3=resp
|
AnzahlStart=resp
|
||||||
db=[]
|
db=[]
|
||||||
#print(resp)
|
|
||||||
ergebniss=''
|
ergebniss=''
|
||||||
requests.packages.urllib3.disable_warnings()
|
requests.packages.urllib3.disable_warnings()
|
||||||
sauce = requests.get('https://www.swr3.de/wraps/fun/filosofie/neu.php?id=11', verify=False)
|
sauce = requests.get('https://www.swr3.de/wraps/fun/filosofie/neu.php?id=1151', verify=False)
|
||||||
soup = bs.BeautifulSoup(sauce.text, 'lxml')
|
soup = bs.BeautifulSoup(sauce.text, 'lxml')
|
||||||
for i in soup.find_all('div'):
|
for i in soup.find_all('div'):
|
||||||
ergebniss=ergebniss+str(i)
|
ergebniss=ergebniss+str(i)
|
||||||
start=(ergebniss.find('href="/wraps/fun/filosofie/neu.php?id=12"> weiter > </a> <a class="linkred" href='))
|
start=(ergebniss.find('href="/wraps/fun/filosofie/neu.php?id=1152&cf=42"> weiter > </a> <a class="linkred" href='))
|
||||||
anzahl=int(ergebniss[start+119:start+123])
|
anzahl=int(ergebniss[start+131:start+135])
|
||||||
start=int(resp)+1+110
|
start=int(resp)+1+110
|
||||||
|
|
||||||
while start <= anzahl:
|
while start <= anzahl:
|
||||||
url='https://www.swr3.de/wraps/fun/filosofie/neu.php?id='+str(start)
|
url='https://www.swr3.de/wraps/fun/filosofie/neu.php?id='+str(start)
|
||||||
sauce = requests.get(url, verify=False)
|
sauce = requests.get(url, verify=False)
|
||||||
soup = bs.BeautifulSoup(sauce.content,'lxml')
|
soup = bs.BeautifulSoup(sauce.content,'lxml')
|
||||||
for i in soup.find_all('strong'):
|
for i in soup.find_all('strong'):
|
||||||
filosophie=(i.text)
|
filosophie=(i.text)
|
||||||
print(filosophie)
|
#print(filosophie)
|
||||||
#print(start,' von ',anzahl)
|
#print(start,' von ',anzahl)
|
||||||
sql = "INSERT INTO `Filosofie`(`Nr`, `Filosofie`) VALUES ('" + str(start) + "','" + filosophie + "')"
|
sql = "INSERT INTO `Filosofie`(`Nr`, `Filosofie`) VALUES ('" + str(start) + "','" + filosophie + "')"
|
||||||
sql_q = "SELECT * FROM Filosofie WHERE Filosofie like '%" + str(filosophie) + "%'"
|
sql_q = "SELECT * FROM Filosofie WHERE Filosofie like '%" + str(filosophie) + "%'"
|
||||||
|
|
@ -50,8 +51,8 @@ while start <= anzahl:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
start +=1
|
start +=1
|
||||||
sql = "SELECT * FROM Filosofie ORDER BY Nr DESC"
|
sql = "SELECT * FROM Filosofie ORDER BY Nr DESC"
|
||||||
resp2 = cursor.execute(sql)
|
AnzahlEnde = cursor.execute(sql)
|
||||||
print('Es wurden ', int(resp2)-int(resp3), ' neue Filosofien der DB hinzugefügt.')
|
print('Es wurden ', int(AnzahlEnde) - int(AnzahlStart), ' neue Filosofien der DB hinzugefügt.')
|
||||||
if len(db)>0:
|
if len(db)>0:
|
||||||
for i in db:
|
for i in db:
|
||||||
print(i)
|
print(i)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue