Skip to content

Commit db6e951

Browse files
committed
ok
1 parent 224561c commit db6e951

6 files changed

Lines changed: 145 additions & 95 deletions

File tree

.idea/workspace.xml

Lines changed: 108 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/日期和时间.py

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

文件读写.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
with open('读写.txt', 'a') as f:
2+
f.write('python3++')

爬虫1.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
from bs4 import BeautifulSoup
33
import os
44
# 下载网页
5-
url = 'http://jandan.net/ooxx/page-2397#comments'
5+
url = 'http://www.yidianzixun.com/home?page=article&id=0G5zThN8&up=0'
66
res = urllib.request.urlopen(url)
7-
html = res.read()
8-
print(html)
7+
html = res.read().decode('utf-8')
98
# 解析网页
109
soup = BeautifulSoup(html, 'html.parser')
11-
result = soup.find_all('img')
10+
result = soup.find_all('img',limit=1)
1211
links = []
1312
for content in result:
14-
links.append('http:' + content.get('src'))
13+
links.append(content.get('src'))
1514
# 下载并存储图片
1615
if not os.path.exists('photo'):
1716
os.makedirs('photo')
1817
i = 0
1918
for link in links:
2019
i += 1
21-
filename = 'photo\\' + 'photo' + str(i) + '.png'
20+
filename = 'photo\\' + 'photo' + str(i) + '.gif'
2221
with open(filename, 'w') as file:
2322
urllib.request.urlretrieve(link, filename)

爬虫练习2.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import urllib.request
2+
from bs4 import BeautifulSoup
3+
import os
4+
url = 'http://www.8she.com/31988.html'
5+
res = urllib.request.urlopen(url)
6+
html = res.read().decode('utf-8')
7+
soup = BeautifulSoup(html, 'html.parser')
8+
result = soup.find_all(class_ = 'aligncenter',limit=15)
9+
# print(result)
10+
links = []
11+
for content in result:
12+
links.append(content.get('src'))
13+
# 下载并存储图片
14+
if not os.path.exists('E:\\rieuse\爬虫图片\photo2'):
15+
os.makedirs('E:\\rieuse\爬虫图片\photo2')
16+
i = 0
17+
for link in links:
18+
i += 1
19+
filename = 'E:\\rieuse\爬虫图片\photo2\\' + 'photo' + str(i) + '.jpg'
20+
with open(filename, 'w') as file:
21+
urllib.request.urlretrieve(link, filename)

类.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Oneclass:
2+
a = 90
3+
def fo(self):
4+
return 'this class'
5+
print(Oneclass.fo)

0 commit comments

Comments
 (0)