一、爬虫基本操作

有些网站和其他网站是有关系(链接),全球的网站就相当于一个蜘蛛网,我们放一只蜘蛛在上面爬,一定能够把网爬个遍。那么如果我们要爬取互联网上内容我们就相当于放一只蜘蛛在上面。

爬虫分为

  • 定向爬虫:只爬这一类网站,有针对性(基本上做的都是定向的)
  • 非定向爬虫:没有目的性,没有针对性,所有链接都爬取

爬虫:就是去某个URL获取指定的内容

  • 发送http请求:http://www.baidu.com
  • 基于正则表达式获取内容

Python实现:(爬取汽车之家的小实例,获取一个新闻的标题)

 import requests
from bs4 import BeautifulSoup response = requests.get("https://www.autohome.com.cn/news/")
# print(response.content)#拿到的是字节信息
response.encoding='gbk' #设置文本的编码
# print(response.text)#拿到的是文本信息
soup = BeautifulSoup(response.text,'html.parser') #html.parser表示html解析器
tag = soup.find(id='auto-channel-lazyload-article')
h3 = tag.find(name="h3")#name表示的是标签名
print(h3)

效果图:

爬取汽车之家的小实例,找到所有的新闻(标题,简介,url,图片)

 import requests
from bs4 import BeautifulSoup #爬取汽车之家的小实例,找到所有的新闻(标题,简介,url,图片) response = requests.get("https://www.autohome.com.cn/news/")
response.encoding='gbk' #设置文本的编码
soup = BeautifulSoup(response.text,'html.parser') #html.parser表示html解析器
li_list = soup.find(id='auto-channel-lazyload-article').find_all('li')
for li in li_list:
title = li.find('h3')
if not title:
continue
summary = li.find('p').text
# li.find('a').attrs#获取到的是一个字典
url = li.find('a').get('href')
img_url = li.find('img').get('src')
img_url = 'http:'+img_url
print(title.text)#title是一个HTML对象,text可以拿到标签里的文本
print(summary)
print(url)
print(img_url)
print("==============")
#下载图片
res = requests.get(img_url)
file_name = "%s.jpg" %(title.text,)
with open(file_name,'wb') as f:
f.write(res.content)

requests模块:

  • obj = requests.get('url')          发送请求
  • obj.content                            得到字节内容
  • obj.text                                  得到HTML内容
  • obj.encoding = 'gbk'              设置内容的编码(显示中文)
  • obj.apparent_encoding         自动检测内容编码      那上面的就可以换成obj.encoding = obj.apparent_encoding

Beautifulsoup模块:

  • soup = BeautifulSoup(obj.text,'html.parser')
  • 标签 = soup.find(name="标签名",id="i1",_class="dd")
  • [标签,] = soup.find_all()
  • 标签.text 获取内容
  • 标签.attrs 获取属性,这里获取的是一个字典,如果想要获得特定的属性,则需要在里面写
  • 标签.get('href.....')获取指定属性的标签内容

Python代码登录github:(requset的Post方法)

1.登录页面发送请求GET,获取csrf_token和cookie(各个网站登录模式不一样)

2.发送POST请求,包含用户名,密码,csrf_token和cookie,如果登录成果可能会返回一个cookie,以后想要登录,只要带着这个cookie就可以了

 import requests
from bs4 import BeautifulSoup
r1 = requests.get('https://github.com/login')
s1 = BeautifulSoup(r1.text,'html.parser')
#获得登录要发送的token
token = s1.find(name='input',attrs={'name':'authenticity_token'}).get('value')
r1_cookie_dict = r1.cookies.get_dict()
#将用户名和密码发送到客户端
'''
commit: Sign in
utf8: ✓
authenticity_token: AVkRqH1wYmS6BsmnR4FS1d+ng19SHJLgZhaY9SemGiHVIzZvKvzmLIIhQ6j5nsisaIXI+A9KLAslu7JoIvdxOg==
login: asdf
password: asdf
''' r2 = requests.post('https://github.com/session',
data={
'commit': 'Sign in',
'utf8': '✓',
'authenticity_token': token,
'login': '729330778@qq.com',
'password': 'wjxm08250920',
},
cookies = r1_cookie_dict
) r2_cookie_dict = r2.cookies.get_dict()
cookie_dic = dict()
cookie_dic.update(r1_cookie_dict)
cookie_dic.update(r2_cookie_dict)
r3 = requests.get(
url='https://github.com/settings/emails',
cookies=cookie_dic,
)
print(r3.text)

requests模块:

  • obj.cookies.get_dict() 拿到一个字典的cookies

下面对requests模块中的参数方法进行详细的介绍:

requests.get(url, params=None, **kwargs)
requests.post(url, data=None, json=None, **kwargs)
requests.put(url, data=None, **kwargs)
requests.head(url, **kwargs)
requests.delete(url, **kwargs)
requests.patch(url, data=None, **kwargs)
requests.options(url, **kwargs) # 以上方法均是在此方法的基础上构建
requests.request(method, url, **kwargs)

Python代码登录抽屉网:(requset的Post方法)

有的时候我们需要爬取的网站做了一些防爬虫措施,按照正常的流程走的话就会出错,爬不到我们想要的数据,得到下面的结果:

我们分析一下,为什么浏览器访问的时候可以得到请求结果,我们发过去的请求过不去呢?还是我们伪造的不够像:

上图是我们正常用浏览器访问之后可以看到的请求结果,我们可以看到请求头中有很多的内容,那我们也可以通过设置请求头的方法,让他们认为我们是通过浏览器进行请求的:

import requests

response = requests.post(
url="https://dig.chouti.com/login",
data = {
'phone':'86xxxxxxxxxxx',
'password' : 'xxxxxxxxxx',
'oneMonth': 1,
},
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
}
)
print(response.text)

这样我们就能够登录成功,进行下一步的操作。

所以总结一句话,如果遇到发爬虫的,我们要看看请求头。

下面我们要对抽屉的新闻进行点赞

首先我们先看一下抽屉点赞需要的操作:首先要登录,然后要发送点赞请求。

也就是说我们获得了这个url,下面我们同样的要设置请求头,避免被拦截。按照往常的思路来说要先登录,request.post,然后在进行点赞post,这样就可以了,但是如果真的这么做了,点赞的操作是完成不了的。

因为这里我们还要考虑cookie,你再提交之后会返回一个cookie,然后通过这个cookie进行验证身份,看看你是否登录了。所以我们要加上这个cookie

但是还有一个问题就是,我们加上了登录之后返回的cookie,可是还是没有办法进行点赞,这个是为什么?有的网站是可以这样进行操作的,但是有的网站他在一开始get到页面的时候先给你发送了一个cookie,这个cookie是后台随机生成的,但是还没有进行授权,只有在你登录了之后该cookie值才会被打上授权了标记,然后使用这个cookie值进行操作的时候就会一帆风顺,所以我们还要在登录之前得到这个后台随机生成的cookie值

 import requests
#1.先访问浏览器,得到一开始的cookie值(未授权的),
r1 = requests.get(
url = "https://dig.chouti.com/all/hot/recent/1",
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
}
)
r1_cookie_dict = r1.cookies.get_dict() #2.发送用户名和密码,带上之前未授权的cookies
response_login = requests.post(
url="https://dig.chouti.com/login",
data = {
'phone':'86xxxxxxxxxxx',
'password' : 'xxxxxxxxxxxx',
'oneMonth': 1,
},
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
},
cookies = r1_cookie_dict
) #点赞
r1 = requests.post(
url = 'https://dig.chouti.com/link/vote?linksId=20307681',
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
},
cookies = r1_cookie_dict
)
print(r1.text)

通过上面的3个操作,我们就能够实现点赞功能个,当然不同的网站,虽然有差异,但是总体是相似的。

我们刷新一下页面,也就能够看到,点赞成功

上面是只对一个新闻进行点赞,如果我们想要对多个新闻进行点赞,那我们应该怎么操作呢?

那我们就需要获取每个新闻的id,然后进行url拼接就好了:

 import requests
from bs4 import BeautifulSoup
#1.先访问浏览器,得到一开始的cookie值(未授权的),
r1 = requests.get(
url = "https://dig.chouti.com/all/hot/recent/1",
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
}
)
r1_cookie_dict = r1.cookies.get_dict() #2.发送用户名和密码,带上之前未授权的cookies
response_login = requests.post(
url="https://dig.chouti.com/login",
data = {
'phone':'86xxxxxxxxxxx',
'password' : 'xxxxxxxxxx',
'oneMonth': 1,
},
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
},
cookies = r1_cookie_dict
) response_index = requests.get(
url = 'https://dig.chouti.com/',
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
}
) soup = BeautifulSoup(response_index.text,'html.parser')
div = soup.find(attrs={'id':'content-list'})
item_list = div.find_all(attrs={'class':'item'})
for item in item_list:
tag = item.find(attrs={'class':'part2'})
if not tag:
continue
nid = tag.get('share-linkid')
# 点赞
r1 = requests.post(
url='https://dig.chouti.com/link/vote?linksId=%s' % nid,
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
},
cookies=r1_cookie_dict
)
print(r1.text)

这里我们就需要用到beautifulsoup,对HTML进行分析,然后获得相应的 div的id

requests模块相关内容

requests中的参数:(红色的参数必须掌握,牢记)

def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: 请求方式,post或者get
:param url: 爬取的url
:param params: get方式传递参数 http://www.baidu.com?k1=v2&nid=888 那这个参数就是一字典的形式表示后面的参数 params={'k1':'v1','mid':888}
:param data: 提供的数据
:param json: 在内部帮助我们进行序列化,如果设置了这个参数,自动把请求头变成了application/json
:param headers: 定义请求头:headers = {'content-type':'application/json'},不同网站请求头不一定相同,有可能是json或者是x-www-form-urlencoded等
:param cookies: 请求之后得到的cookies值 :param files: 可以进行上传文件(optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
to add for the file.
:param auth: 定制请求头,验证api规则,把用户名密码弄成请求头(获取不到HTML的form,如路由器登录)(optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How long to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param allow_redirects: 是否允许重定向(optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.如果允许,拿到的就是重定向之后的结果
:type allow_redirects: bool
:param proxies: ip代理,使用不同的ip爬取数据(optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: 有些网站需要证书,基于https,需要确认是不是要往下走,就好像yum安装时要输入y/N,(optional) whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to ``True``.
:param stream:发文件的时候边发边取,不是一次性放入内存 (optional) if ``False``, the response content will be immediately downloaded.
:param cert: 证书,特殊的网站有(optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
:return: :class:`Response <Response>` object
:rtype: requests.Response Usage:: >>> import requests
>>> req = requests.request('GET', 'http://httpbin.org/get')
<Response [200]>
"""

使用方法展示:

def param_method_url():
# requests.request(method='get', url='http://127.0.0.1:8000/test/')
# requests.request(method='post', url='http://127.0.0.1:8000/test/')
pass def param_param():
# - 可以是字典
# - 可以是字符串
# - 可以是字节(ascii编码以内) # requests.request(method='get',
# url='http://127.0.0.1:8000/test/',
# params={'k1': 'v1', 'k2': '水电费'}) # requests.request(method='get',
# url='http://127.0.0.1:8000/test/',
# params="k1=v1&k2=水电费&k3=v3&k3=vv3") # requests.request(method='get',
# url='http://127.0.0.1:8000/test/',
# params=bytes("k1=v1&k2=k2&k3=v3&k3=vv3", encoding='utf8')) # 错误
# requests.request(method='get',
# url='http://127.0.0.1:8000/test/',
# params=bytes("k1=v1&k2=水电费&k3=v3&k3=vv3", encoding='utf8'))
pass def param_data():
# 可以是字典
# 可以是字符串
# 可以是字节
# 可以是文件对象 # requests.request(method='POST',
# url='http://127.0.0.1:8000/test/',
# data={'k1': 'v1', 'k2': '水电费'}) # requests.request(method='POST',
# url='http://127.0.0.1:8000/test/',
# data="k1=v1; k2=v2; k3=v3; k3=v4"
# ) # requests.request(method='POST',
# url='http://127.0.0.1:8000/test/',
# data="k1=v1;k2=v2;k3=v3;k3=v4",
# headers={'Content-Type': 'application/x-www-form-urlencoded'}
# ) # requests.request(method='POST',
# url='http://127.0.0.1:8000/test/',
# data=open('data_file.py', mode='r', encoding='utf-8'), # 文件内容是:k1=v1;k2=v2;k3=v3;k3=v4
# headers={'Content-Type': 'application/x-www-form-urlencoded'}
# )
pass def param_json():
# 将json中对应的数据进行序列化成一个字符串,json.dumps(...)
# 然后发送到服务器端的body中,并且Content-Type是 {'Content-Type': 'application/json'}
requests.request(method='POST',
url='http://127.0.0.1:8000/test/',
json={'k1': 'v1', 'k2': '水电费'}) def param_headers():
# 发送请求头到服务器端
requests.request(method='POST',
url='http://127.0.0.1:8000/test/',
json={'k1': 'v1', 'k2': '水电费'},
headers={'Content-Type': 'application/x-www-form-urlencoded'}
) def param_cookies():
# 发送Cookie到服务器端
requests.request(method='POST',
url='http://127.0.0.1:8000/test/',
data={'k1': 'v1', 'k2': 'v2'},
cookies={'cook1': 'value1'},
)
# 也可以使用CookieJar(字典形式就是在此基础上封装)
from http.cookiejar import CookieJar
from http.cookiejar import Cookie obj = CookieJar()
obj.set_cookie(Cookie(version=0, name='c1', value='v1', port=None, domain='', path='/', secure=False, expires=None,
discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False,
port_specified=False, domain_specified=False, domain_initial_dot=False, path_specified=False)
)
requests.request(method='POST',
url='http://127.0.0.1:8000/test/',
data={'k1': 'v1', 'k2': 'v2'},
cookies=obj) def param_files():
# 发送文件
# file_dict = {
# 'f1': open('readme', 'rb')
# }
# requests.request(method='POST',
# url='http://127.0.0.1:8000/test/',
# files=file_dict) # 发送文件,定制文件名
# file_dict = {
# 'f1': ('test.txt', open('readme', 'rb'))
# }
# requests.request(method='POST',
# url='http://127.0.0.1:8000/test/',
# files=file_dict) # 发送文件,定制文件名
# file_dict = {
# 'f1': ('test.txt', "hahsfaksfa9kasdjflaksdjf")
# }
# requests.request(method='POST',
# url='http://127.0.0.1:8000/test/',
# files=file_dict) # 发送文件,定制文件名
# file_dict = {
# 'f1': ('test.txt', "hahsfaksfa9kasdjflaksdjf", 'application/text', {'k1': '0'})
# }
# requests.request(method='POST',
# url='http://127.0.0.1:8000/test/',
# files=file_dict) pass def param_auth():
from requests.auth import HTTPBasicAuth, HTTPDigestAuth ret = requests.get('https://api.github.com/user', auth=HTTPBasicAuth('wupeiqi', 'sdfasdfasdf'))
print(ret.text) # ret = requests.get('http://192.168.1.1',
# auth=HTTPBasicAuth('admin', 'admin'))
# ret.encoding = 'gbk'
# print(ret.text) # ret = requests.get('http://httpbin.org/digest-auth/auth/user/pass', auth=HTTPDigestAuth('user', 'pass'))
# print(ret)
# def param_timeout():
# ret = requests.get('http://google.com/', timeout=1)
# print(ret) # ret = requests.get('http://google.com/', timeout=(5, 1))
# print(ret)
pass def param_allow_redirects():
ret = requests.get('http://127.0.0.1:8000/test/', allow_redirects=False)
print(ret.text) def param_proxies():
# proxies = {
# "http": "61.172.249.96:80",
# "https": "http://61.185.219.126:3128",
# } # proxies = {'http://10.20.1.128': 'http://10.10.1.10:5323'} # ret = requests.get("http://www.proxy360.cn/Proxy", proxies=proxies)
# print(ret.headers) # from requests.auth import HTTPProxyAuth
#
# proxyDict = {
# 'http': '77.75.105.165',
# 'https': '77.75.105.165'
# }
# auth = HTTPProxyAuth('username', 'mypassword')
#
# r = requests.get("http://www.google.com", proxies=proxyDict, auth=auth)#代理的时候把用户名和密码一起带上
# print(r.text) pass def param_stream():
ret = requests.get('http://127.0.0.1:8000/test/', stream=True)
print(ret.content)
ret.close() # from contextlib import closing
# with closing(requests.get('http://httpbin.org/get', stream=True)) as r:
# # 在此处理响应。
# for i in r.iter_content():
# print(i) def requests_session():
import requests session = requests.Session() ### 1、首先登陆任何页面,获取cookie i1 = session.get(url="http://dig.chouti.com/help/service") ### 2、用户登陆,携带上一次的cookie,后台对cookie中的 gpsd 进行授权
i2 = session.post(
url="http://dig.chouti.com/login",
data={
'phone': "",
'password': "xxxxxx",
'oneMonth': ""
}
) i3 = session.post(
url="http://dig.chouti.com/link/vote?linksId=8589623",
)
print(i3.text)

关于数据传送的形式:

对于数据是以data形式还是以json格式发送过去,这个我们第一可以看调试:

如果是Form Data 的形式的话那么我们就可以用data,如果是payload字样的时候就使用json形式发送相关数据。

当然,如果你认为这个还是比较麻烦的,我们可以就使用data:

data = json.dumps({
'phone':'86xxxxxx',
'password' : xxxxxx',
'oneMonth': 1,
}),

一旦使用了json.dumps就会把数据变成字符串,也就相当于变成了json格式的数据。

python爬虫----基本操作的更多相关文章

  1. [python]爬虫学习(一)

    要学习Python爬虫,我们要学习的共有以下几点(python2): Python基础知识 Python中urllib和urllib2库的用法 Python正则表达式 Python爬虫框架Scrapy ...

  2. Python爬虫学习:三、爬虫的基本操作流程

    本文是博主原创随笔,转载时请注明出处Maple2cat|Python爬虫学习:三.爬虫的基本操作与流程 一般我们使用Python爬虫都是希望实现一套完整的功能,如下: 1.爬虫目标数据.信息: 2.将 ...

  3. Python爬虫入门教程 12-100 半次元COS图爬取

    半次元COS图爬取-写在前面 今天在浏览网站的时候,忽然一个莫名的链接指引着我跳转到了半次元网站 https://bcy.net/ 打开之后,发现也没有什么有意思的内容,职业的敏感让我瞬间联想到了 c ...

  4. @1-2初识Python爬虫

    初识Python爬虫 Python爬虫(入门+进阶)     DC学院 环境搭建: Python2与Python3的差异:python2与python3整体差异不大,大多是一些语法上的区别,考虑到py ...

  5. Python爬虫教程

    Python爬虫(1):基本原理 Python爬虫(2):Requests的基本用法 Python爬虫(3):Requests的高级用法 Python爬虫(4):Beautiful Soup的常用方法 ...

  6. 爬虫基本操作、requests和BeautifulSoup

    1. 爬虫基本操作 例如舆情系统: 获取汽车之家新闻放到自己数据库里,创建自己的app,发布内容,注明来源,自己创业. URL指定内容获取到 - 发送Http请求:http://www.autohom ...

  7. python 爬虫(转,我使用的python3)

      原文地址:http://blog.csdn.net/pi9nc/article/details/9734437 [Python]网络爬虫(一):抓取网页的含义和URL基本构成 分类: 爬虫 Pyt ...

  8. Python爬虫入门教程: 半次元COS图爬取

    半次元COS图爬取-写在前面 今天在浏览网站的时候,忽然一个莫名的链接指引着我跳转到了半次元网站 https://bcy.net/ 打开之后,发现也没有什么有意思的内容,职业的敏感让我瞬间联想到了 c ...

  9. 小白学 Python 爬虫(21):解析库 Beautiful Soup(上)

    小白学 Python 爬虫(21):解析库 Beautiful Soup(上) 人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前 ...

随机推荐

  1. Miller_Rabin(米勒拉宾)素数测试

    2018-03-12 17:22:48 米勒-拉宾素性检验是一种素数判定法则,利用随机化算法判断一个数是合数还是可能是素数.卡内基梅隆大学的计算机系教授Gary Lee Miller首先提出了基于广义 ...

  2. 51nod-1455-dp/缩小范围

    1455 宝石猎人  题目来源: CodeForces 基准时间限制:2 秒 空间限制:131072 KB 分值: 40 难度:4级算法题  收藏  关注 苏塞克岛是一个有着30001个小岛的群岛,这 ...

  3. CentOS 6.5安装和配置ngix

    一.安装配置ngix 这里用wget直接拉取并安装资源文件 首先安装必要的库(nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库). ...

  4. 处理EXCEL11问题

    程序原本是好使的,但是自从卸载OFFICE11而安装14后,程序无法启动. 重新安装2003 ,然后,删除原引用 Microsoft.Office.Interop.Excel,然后添加引用,浏览,找到 ...

  5. 一. Spring框架防XXS跨站攻击

    使用 Spring 框架进行 Java Web 开发,可以在 web.xml 文件中设置 HTML encode,在 JSP 文件页面元素 form 中确定实施. web.xml 加上: <co ...

  6. Yii Model

    REFs 自动生成代码 创建第一个Yii应用 创建模型 Yii 用户登陆机制

  7. VMware 虚拟机快照、克隆、磁盘扩容

    1. 快照 快照是虚拟机某个时间点上完整系统的镜像,可以在虚拟机内部通过快照文件恢复系统到之前的节点. 拍摄快照: 恢复快照: 2. 克隆 克隆是原始虚拟机全部状态的一个拷贝,是脱离原始虚拟机独立存在 ...

  8. springboot结合开源editor.md集成markdonw编辑器

    今天来实现一个简单的功能,通常blog后台编辑大多使用的是富文本编辑器,比如百度的Ueditor,比较轻巧的wangEditor,那么如何使用开源editor.md的markdown呢? 搭建一个sp ...

  9. Java---SSH(MVC)面试

    Java---SSH(MVC) 1.        谈谈你mvc的理解 MVC是Model—View—Controler的简称.即模型—视图—控制器.MVC是一种设计模式,它强制性的把应用程序的输入. ...

  10. python eval, exec. compile

    compile 编译某段代码, (将一个字符串编译为字节代码), 以方便重复调用. exec 可以理解为和if, for一样是一个语法声明, 而不是一个函数. 注意globals和locals的含义. ...