Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. import requests, smtplib, lxml
  3. from email.mime.multipart import MIMEMultipart
  4. from email.mime.text import MIMEText
  5.  
  6.  
  7. source_mmarocks = requests.get('http://mmarocks.pl').text
  8. soup_mmarocks = BeautifulSoup(source_mmarocks, 'lxml')
  9.  
  10. source_grappler = requests.get('http://grapplerinfo.pl').text
  11. soup_grappler = BeautifulSoup(source_grappler, 'lxml')
  12.  
  13. source_lowking = requests.get('http://lowking.pl').text
  14. soup_lowking = BeautifulSoup(source_lowking, 'lxml')
  15.  
  16.  
  17.  
  18. def mmarocks():
  19. print('==========================MMAROCKS====================')
  20. index = 0
  21. limit = 10
  22. for hd in soup_mmarocks.find_all('div', class_="td-module-thumb"):
  23. header = hd.a['title']
  24. print(header)
  25. header_link = hd.a['href']
  26. print(header_link)
  27. print()
  28. index += 1
  29. if index == limit:
  30. print()
  31. print()
  32. break
  33.  
  34.  
  35. def grappler():
  36. print('========================GRAPPLER======================')
  37. for article in soup_grappler.find_all('article'):
  38. try:
  39. main_headline = article.find('div', class_='entry').h3.a.text
  40. print(main_headline)
  41.  
  42. except:
  43. break
  44.  
  45. main_link = article.find('div', class_='entry').h3.a['href']
  46. print(main_link)
  47. print()
  48.  
  49.  
  50. def lowking():
  51. print('========================LOWKING======================')
  52. main_news = soup_lowking.find('div', class_='main-text').h1.text
  53. print(main_news)
  54. main_link = soup_lowking.find('div', class_='main-story').a['href']
  55. print(main_link)
  56. print()
  57.  
  58.  
  59. def lowking1():
  60. limit = 10
  61. index = 0
  62. for sub_art in soup_lowking.find_all('div', class_='sub-story'):
  63. sub_head = sub_art.h2.text
  64. print(sub_head)
  65.  
  66. sub_link = sub_art.a['href']
  67. print(sub_link)
  68. print()
  69. index += 1
  70. if index == limit:
  71. break
  72.  
  73. def lowking2():
  74. limit = 10
  75. index = 0
  76. for artykul in soup_lowking.find_all('div', class_='archive-text'):
  77. regular_news = artykul.h2.text
  78. print(regular_news)
  79.  
  80. tresc = artykul.p.text
  81. print(tresc)
  82.  
  83. link = artykul.h2.a['href']
  84. print(link)
  85.  
  86. print()
  87. index += 1
  88. if index == limit:
  89. break
  90.  
  91.  
  92. def gotowymail():
  93. return mmarocks(),grappler(), lowking(), lowking1(), lowking2()
  94.  
  95.  
  96.  
  97.  
  98. nowygotowymail = gotowymail()
  99.  
  100. f = open("prasowka.txt","w+")
  101.  
  102. f.write(nowygotowymail)
  103.  
  104. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement