質問編集履歴
1
完成コード追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -93,3 +93,55 @@
|
|
93
93
|
|
94
94
|
|
95
95
|
よろしくお願いしますm(__)m
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
# できましたー(≧∇≦)b
|
100
|
+
|
101
|
+
[jun68ykt](https://teratail.com/users/jun68ykt)さま、ありがとうございます!
|
102
|
+
|
103
|
+
おかげさまでできました(*^^*)
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
```
|
108
|
+
|
109
|
+
# -*- coding: utf-8 -*-
|
110
|
+
|
111
|
+
from bs4 import BeautifulSoup
|
112
|
+
|
113
|
+
import requests
|
114
|
+
|
115
|
+
import csv
|
116
|
+
|
117
|
+
import re
|
118
|
+
|
119
|
+
import warnings
|
120
|
+
|
121
|
+
warnings.filterwarnings('ignore')
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
r = requests.get("https://www.freelancer.com/archives/python/2018-40/")
|
126
|
+
|
127
|
+
soup_content = BeautifulSoup(r.content, "html.parser")
|
128
|
+
|
129
|
+
f1 = open('r.txt', 'w')
|
130
|
+
|
131
|
+
f1.write(r.text)
|
132
|
+
|
133
|
+
f1.close
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
soup = BeautifulSoup(r.text)
|
138
|
+
|
139
|
+
with open('pythonHref.csv', 'w+',newline='',encoding='utf-8') as f:
|
140
|
+
|
141
|
+
writer = csv.writer(f, lineterminator='\n')
|
142
|
+
|
143
|
+
for link in soup.find_all('a', {'href': re.compile(r'^/projects/python/')}):
|
144
|
+
|
145
|
+
writer.writerow([link.get('href')])
|
146
|
+
|
147
|
+
```
|