質問編集履歴
2
発生している問題を記載しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,7 +24,11 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
https://news.google.com/./articles/CAIiEA4g--wP9W2E5wCTRDtFzvYqGQgEKhAIACoHCAowtv3_CjCSposDMLX54gU?hl=en-US&gl=US&ceid=US%3Aen
|
28
|
+
|
27
|
-
。
|
29
|
+
というようなリンクのようなものが多数表示されます。
|
30
|
+
|
31
|
+
|
28
32
|
|
29
33
|
|
30
34
|
|
@@ -70,8 +74,6 @@
|
|
70
74
|
|
71
75
|
|
72
76
|
|
73
|
-
|
74
|
-
|
75
77
|
### 補足情報(FW/ツールのバージョンなど)
|
76
78
|
|
77
79
|
|
1
ソースコードを入力しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
|
27
|
+
。
|
28
28
|
|
29
29
|
|
30
30
|
|
@@ -32,7 +32,41 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
+
import urllib.request
|
36
|
+
|
37
|
+
from bs4 import BeautifulSoup
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
class Scraper:
|
44
|
+
|
45
|
+
def __init__(self, site):
|
46
|
+
|
35
|
-
|
47
|
+
self.site = site
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
def scrape(self):
|
52
|
+
|
53
|
+
response = urllib.request.urlopen(self.site)
|
54
|
+
|
55
|
+
html = response.read()
|
56
|
+
|
57
|
+
soup = BeautifulSoup(html, "html.parser")
|
58
|
+
|
59
|
+
for tag in soup.find_all("a"):
|
60
|
+
|
61
|
+
url = tag.get("href")
|
62
|
+
|
63
|
+
if url and "article" in url:
|
64
|
+
|
65
|
+
print("\n" + "https://news.google.com/"+url)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
Scraper('https://news.google.com/').scrape()
|
36
70
|
|
37
71
|
|
38
72
|
|
@@ -48,7 +82,7 @@
|
|
48
82
|
|
49
83
|
requests
|
50
84
|
|
51
|
-
を使ってます。
|
85
|
+
VisualStudio Codeを使ってます。
|
52
86
|
|
53
87
|
|
54
88
|
|