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