J.Z's BLOG


  • 首页

  • 归档

  • 标签

  • 分类

  • 关于

  • 搜索

【教程】CPH机场购买前往Karlskrona的火车票

发表于 2018-09-07 | 分类于 生活

…………

阅读全文 »

leetcode-4.Median of Two Sorted Arrays

发表于 2018-08-10 | 分类于 leetcode

There are two sorted arrays nums1 and nums2 of size m and n respectively.

Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

You may assume nums1 and nums2 cannot be both empty.

阅读全文 »

理解RESTful架构

发表于 2018-07-17

(转载)理解RESTful架构 - 阮一峰的网络日志

起源

REST这个词,是Roy Thomas Fielding在他2000年的博士论文中提出的。

Fielding是一个非常重要的人,他是HTTP协议(1.0版和1.1版)的主要设计者、Apache服务器软件的作者之一、Apache基金会的第一任主席。所以,他的这篇论文一经发表,就引起了关注,并且立即对互联网开发产生了深远的影响。

阅读全文 »

Mac&Linux命令自查

发表于 2018-07-15 | 分类于 学习

Linux rm命令 删除文件夹

Linux删除目录很简单,很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中,现在使用rm -rf命令即可。

直接rm就可以了,不过要加两个参数-rf 即:rm -rf 目录名字

-r 就是向下递归,不管有多少级目录,一并删除

-f 就是直接强行删除,不作任何提示的意思

注意事项:使用这个rm -rf的时候一定要格外小心,linux没有回收站的

阅读全文 »

Mac第一篇

发表于 2018-07-10

我很开心呢

测试一下行不行

阅读全文 »

5-21学习小结

发表于 2018-05-21 | 分类于 学习

Normal equation

标准方程能够快速计算(在n相对较小的情况)出θ的值不需要迭代。

Gradient Descent Normal Equation
Need to choose alpha No need to choose alpha
Needs many iterations No need to iterate
O (kn^2 ) O (n^3), need to calculate inverse of X^T*X
Works well when n is large Slow if n is very large
阅读全文 »

5-10学习小结

发表于 2018-05-10 | 分类于 学习

Model Representation

监督算法模型,给予一个训练数据集到学习算法,然后得到一个hypothesis(假设)函数 – 输入X值后能预测相应的Y值

阅读全文 »

5.2学习小结

发表于 2018-05-02 | 分类于 学习

Supervised learning

  • 给algorithm一个data set in which “right answers” given
  • Regression: predict continuous valued output
  • Classification = discrete valued output(0 or 1)

Unsupervised learning

  • just give algorithm a data set nothing else(no extra information)不知道数据集的意义
  • clustering algorithm 聚合算法
  • Cocktail party problem 鸡尾酒会算法
  • Octave
    diabetes

Bachelor, Master and Doctor

发表于 2018-05-02 | 分类于 学习

BA: 文学学士学位(Bachelor of Arts)

BBA: 工商业管理学士学位(Bachelor of Business Administration)

BS: 理学学士学位(Bachelor of sciense)

MA:文学硕士学位(Master of Arts)

MS:理学硕士学位(Master of Sciense)

MBA:工商管理硕士学位(Master of Business Administration)

PhD:哲学博士学位,文理科均可。(Doctor of Philosophy)

python简单爬虫爬取豆瓣影人照片

发表于 2018-03-18 | 分类于 学习
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests, os, re
from urllib.parse import urljoin

# 豆瓣图片爬虫

class SpiderMain(object):


# 获取该页面上单独图片页面的链接
def _get_new_urls(self, page_url, soup):
new_urls = set()
reg = r"https://movie.douban.com/celebrity/" + page_url.split('/')[4] + r"/photo/\d+/$" #正则表达式
links = soup.find_all('a', href=re.compile(reg))
for link in links:
new_url = link['href']
new_full_url = urljoin(page_url, new_url)
new_urls.add(new_full_url)
return new_urls

#获取该名人的姓名作为图片文件夹名
def _get_name(self, root_url):
response = requests.get(root_url)
html_cont = response.content
soup = BeautifulSoup(html_cont, 'html.parser')
name = soup.find("div", attrs={"id":"content"}).h1.text.split()[0]
return name

# 爬图片开始喽
def crawl(self, root_url):
dir_name = self._get_name(root_url)
dirIsExist = os.path.exists(os.getcwd() + r'\\douban\\%s'%dir_name) #该文件夹是否存在
if not dirIsExist:
os.makedirs(os.getcwd() + r'\\douban\\%s'%dir_name) #创建图片文件夹
os.chdir(os.path.join(os.getcwd(), r'douban\\%s'%dir_name)) #进入该文件夹

n = 1 #图片数量
page = 0 #图片页码

while page < 2:
url_ = root_url + "photos/?start=%d" % (page*40)

html_cont = requests.get(url_).content

soup = BeautifulSoup(html_cont, 'html.parser')

urls = self._get_new_urls(url_, soup)

for url in urls:
pic_name = str(n) + '.jpg'
img_url = "https://img1.doubanio.com/view/photo/l/public/p" + url.split('/')[6] + ".jpg"
pic = requests.get(img_url)
with open(pic_name, 'wb') as file: #open函数?
file.write(pic.content)
file.flush()
file.close()
print("Crawl " + str(n) + " : " + img_url)
n += 1
page += 1
print("Crawl succeed !")


if __name__=="__main__":
root_url = "https://movie.douban.com/celebrity/%d/" % 1274424 #只需修改该影人的豆瓣ID
obj_spider = SpiderMain()
obj_spider.crawl(root_url)

123
Jesse Zheng

Jesse Zheng

Passion makes perfect.

26 日志
7 分类
27 标签
RSS
GitHub Weibo E-Mail YouTube Instagram Bilibili
© 2020 Jesse Zheng
本站访客数:
|
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4