Skip to content

Commit

Permalink
Finished NewsScrape
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheyonix committed Jan 30, 2020
1 parent 8443cdf commit 102fdd1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ env
*.app.py.s*
.py.s*
__pycache__
*.db
41 changes: 37 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, news_urls):

#self.summary = article.summary

print(self.summary)
#print(self.summary)

new_article = Articlelist(title=self.title, author=self.author, summary=self.summary)

Expand All @@ -69,8 +69,6 @@ def __init__(self, news_urls):



def get_article(self):
return [self.title, self.author, self.summary]



Expand Down Expand Up @@ -100,7 +98,7 @@ def index():


# loop through all blog posts in home page
blog_posts = soup1.find("div", class_="blog-posts")
#blog_posts = soup1.find("div", class_="blog-posts")

news_urls = []

Expand All @@ -116,6 +114,41 @@ def index():

site1 = NewsArticle(news_urls)

# site 2

news_urls.clear()

site2_content = requests.get('https://www.ehackingnews.com/search/label/Cyber%20Crime?max-results=7')

site2_data = site2_content.text

soup2 = BeautifulSoup(site2_data, 'html.parser')

# loop through all blog posts in home page

blog_posts = soup2.find_all('article', class_="home-post")


for blog_post in blog_posts:

#print(blog_post.h2.a.get('href'))

url = blog_post.h2.a.get('href')

news_urls.append(url)

site2 = NewsArticle(news_urls)

#for h2 in h2s:

#print(h2.text)

# url_link = soup2.find('a')

# url = url_link.get('href')

# news_urls.append(url)




Expand Down
Binary file modified news_scrape.db
Binary file not shown.
2 changes: 2 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<div class="container">
<h1>NewsScrape</h1>


{% for article in articles %}
<div>
<h3>{{ article.title }} | <span>{{ article.author }}</span></h3>
Expand Down

0 comments on commit 102fdd1

Please sign in to comment.