Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dbs2017
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sommerann
dbs2017
Commits
17b65b30
Commit
17b65b30
authored
Jun 8, 2017
by
sommerann
Browse files
Options
Downloads
Patches
Plain Diff
first version with import
parent
eb22c268
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
heise.py
+38
-0
38 additions, 0 deletions
heise.py
with
38 additions
and
0 deletions
heise.py
0 → 100644
+
38
−
0
View file @
17b65b30
# python 3.6.1
# imports
from
bs4
import
BeautifulSoup
import
requests
import
csv
def
has_source
(
tag
):
# filtering the search results
return
tag
.
has_attr
(
'
data-sourcechannel
'
)
and
tag
.
has_attr
(
'
class
'
)
# scraper website: https://www.heise.de/thema/https
def
main
():
fobj
=
open
(
'
heise.csv
'
,
'
w
'
)
# open file
csvw
=
csv
.
writer
(
fobj
,
delimiter
=
'
;
'
)
# create csv writer, set delimiter to ;
r
=
requests
.
get
(
"
https://www.heise.de/thema/https
"
)
#
soup
=
BeautifulSoup
(
r
.
content
,
"
lxml
"
)
headlines
=
(
soup
.
find_all
(
has_source
))
#find the corresponding entries
for
line
in
headlines
:
txt
=
[
"
Überschrift:
"
]
for
header
in
line
.
header
:
#filter only for the header-tag
txt
.
append
(
header
)
csvw
.
writerow
(
txt
)
#print(txt)
fobj
.
close
()
# close file
print
(
"
\n
DONE !
\n\n\n
Heise.de was scraped completely.
\n
"
)
# main program
if
__name__
==
'
__main__
'
:
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment