response = requests.get("http://wxqqyy.info/thread-9227343-1-1.html", headers={"Accept-Encoding" : ""})
Allow Deny語句了解一下
< 在界面寫吧 或者網(wǎng)站找個(gè)小于符號 不用鍵盤打出來的小于號
大概是這樣:
import requests
import re
url_list = ['http://top.chinaz.com/hangye/index_news.html']
url_list.extend(['http://top.chinaz.com/hangye/index_news_{}.html'.format(pages) for pages in range(2, 68)])
DOMAIN = 'http://top.chinaz.com'
def parse_detail(url):
full_url = DOMAIN + url
print('process:', full_url)
res = requests.get(full_url)
res.encoding = 'utf-8'
content = res.text
web_name = re.search('<h2 class="h2Title fl">(.*?)</h2>', content).group(1)
web_url = re.search('<h2 class="h2Title fl">.*?</h2><p.*?href="(.*?)" target="_blank" >.*?</a>', content).group(1)
web_description = re.search('<p class="webIntro">(.*?)</p>', content).group(1)
print('網(wǎng)站名稱:' + web_name)
print('網(wǎng)址:' + web_url)
print('網(wǎng)站簡介:' + web_description)
for url in url_list:
print('list:', url)
res = requests.get(url)
res.encoding = 'utf-8'
content = res.text
detail_urls = re.findall('<div class="leftImg"><a name=".*?href="(.*?)">', content)
for url in detail_urls:
parse_detail(url)
我回答過的問題: Python-QA
錯(cuò)誤提示是ValueError: Unknown string format, 所以就指定format:
import pandas as pd
df = pd.DataFrame(data={'time': ['1 days 02:59:45.000000000']})
df['time'] = pd.to_datetime(df['time'], format='%d days %H:%M:%S.%f').values.astype('datetime64[h]')
df
不知道是不是你所需要的.
無關(guān)。
這個(gè)字段有兩個(gè)名字,一個(gè)是 d_type_id,它是 python 層面的;另一個(gè)是 device_type_id,它是最終存在數(shù)據(jù)庫中的列名。而你通過實(shí)例 Device 訪問,是在 python 層面的,如果訪問 device_type_id 是會報(bào)錯(cuò)的:
>>> d.device_type_id
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'Device' object has no attribute 'device_type_id'
你在 python shell 中查看 dir(Device) 或者 dir(d) 都是找不到 device_type_id 的,只有 'd_type', 'd_type_id',:
>>> d.d_type # 一個(gè) DeviceType 實(shí)例
<DeviceType: first type>
>>> d.d_type_id # device_type_id 列內(nèi)存儲值
1log_df[['id','device']].groupby(['id'])['device'].apply(lambda x:len(set(x)))
應(yīng)該使用模型操作。 可以先看一下QT的 MVC架構(gòu)
app.run()
它是調(diào)用flask內(nèi)置的自己實(shí)現(xiàn)的一個(gè)單線程服務(wù)器,通常是用在開發(fā)測試的情況下,因?yàn)檎鎸?shí)情況下必須考慮到并發(fā),nginx + gunicorn,是利用nginx高并發(fā)的優(yōu)勢,nginx收到http請求之后,把他轉(zhuǎn)發(fā)給wsgi服務(wù)器gunicorn,gunicorn上運(yùn)行flask應(yīng)用,處理請求之后再返回給nginx
下面這段是flask run函數(shù)的源碼,你可以找來看看
from werkzeug.serving import run_simple
try:
run_simple(host, port, self, **options)
finally:
# reset the first request information if the development server
# reset normally. This makes it possible to restart the server
# without reloader and that stuff from an interactive shell.
self._got_first_request = FalseQuite simple:
>>> print '"Hello,\\nworld!"'.decode('string_escape')
"Hello,
world!"
>>> data = json.loads('{\"count\":8,\"sub_images\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/470700000c7084773fb2\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/470700000c7084773fb2\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/470700000c7084773fb2\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/470700000c7084773fb2\"}],\"uri\":\"origin\\/470700000c7084773fb2\",\"height\":1590},{\"url\":\"http:\\/\\/p9.pstatp.com\\/origin\\/47050001b69355a0bf1b\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p9.pstatp.com\\/origin\\/47050001b69355a0bf1b\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/47050001b69355a0bf1b\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/47050001b69355a0bf1b\"}],\"uri\":\"origin\\/47050001b69355a0bf1b\",\"height\":1557},{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/470300020761150d671a\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/470300020761150d671a\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/470300020761150d671a\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/470300020761150d671a\"}],\"uri\":\"origin\\/470300020761150d671a\",\"height\":1552},{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/47000002200f2a0a9020\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/47000002200f2a0a9020\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/47000002200f2a0a9020\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/47000002200f2a0a9020\"}],\"uri\":\"origin\\/47000002200f2a0a9020\",\"height\":1575},{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/470000022011d5569ccb\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/470000022011d5569ccb\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/470000022011d5569ccb\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/470000022011d5569ccb\"}],\"uri\":\"origin\\/470000022011d5569ccb\",\"height\":1588},{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/4700000220127db96444\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/4700000220127db96444\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/4700000220127db96444\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/4700000220127db96444\"}],\"uri\":\"origin\\/4700000220127db96444\",\"height\":1561},{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/46ff000532e33a9fa35a\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/46ff000532e33a9fa35a\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/46ff000532e33a9fa35a\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/46ff000532e33a9fa35a\"}],\"uri\":\"origin\\/46ff000532e33a9fa35a\",\"height\":1563},{\"url\":\"http:\\/\\/p9.pstatp.com\\/origin\\/470700000c7b871a5fae\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p9.pstatp.com\\/origin\\/470700000c7b871a5fae\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/470700000c7b871a5fae\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/470700000c7b871a5fae\"}],\"uri\":\"origin\\/470700000c7b871a5fae\",\"height\":1575}],\"max_img_width\":1178,\"labels\":[],\"sub_abstracts\":[\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \"],\"sub_titles\":[\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\"]}'.decode('string_escape'))
>>>
>>> data["count"]
8
>>> 也是新手 看到紅色就當(dāng)成報(bào)錯(cuò)哈哈
首先,找出獲取公司列表的接口地址:https://www.qichacha.com/gong...
然后,看看請求參數(shù):key,type
如果還是不行,那就可能還有別的參數(shù)校驗(yàn)規(guī)則,通常是在請求頭里。比如cookie,或者別的自定義字段。
1.首選zen of python(import this即可看到Explicit is better than implicit.)中提到顯式勝于隱式,所以參數(shù)中必須有個(gè)首參數(shù)self或其他的名字,而不是像c++這種高級語言有隱式的作用域
2.為什么self不是關(guān)鍵字,原因很簡單Python是動態(tài)語言,比如你總是可以對普通的函數(shù)動態(tài)綁定為方法,所以不可能限定self關(guān)鍵字:
import types
class A:
def __init__(self):
self.bar = 'bar'
def foo(bar):
print(bar.bar)
a = A()
a.foo = types.MethodType(foo, a)
a.foo()
3. 還想到一個(gè)題外話,有一個(gè)玩笑是“基于Python的 web framework比python的關(guān)鍵字還多”,于是有人和作者提議多加一些關(guān)鍵字,但是被拒絕了,這也印證了Zen of Python的另外兩句話:Simple is better than complex.Complex is better than complicated.
沒試過寫到service里面,不過親測寫到rc.local里面是可以的
osp = form.save(commit=True)
osp.order.add(*order_goods)
# osp.save()
m2m 關(guān)系只有當(dāng)兩邊都在數(shù)據(jù)庫中存在時(shí)才能添加
a = [45, 67, 89, 90, 234, 67, 78123131, 4645645, 1231231]
b = ["qweqw", "qeqeqe", "sd", "fsdf"]
for i, v in enumerate(b):
a.insert(i*3 + 2, v)
print a1.cookie是在header里的
2.UA也是放header里的
隨便打開chrome的控制臺,你就能看到網(wǎng)絡(luò)請求,可以看出哪些是header,哪些是data,哪些是query string
想要更深入的了解的話可以看看圖解http這本書
你的 app.config 里面沒有定義 FLASK_ADMIN
應(yīng)該是你定義的related_name和User的id屬性發(fā)生了沖突.
如果你沒有給外鍵定義related_name屬性,那么反向引用的時(shí)候就是: User.usrMes_set.all()
你添加了related_name='id'后就成了: User.id.all(), 這樣就和調(diào)用id屬性User.id有沖突了.
另外對同一個(gè)model的兩個(gè)外鍵,related_name不能重名
你不理解哪塊?
整體實(shí)現(xiàn)是有一個(gè)v-for所有notice類的組件。你每調(diào)用一次就往里push一個(gè)。
1.success->message
// 幾種方法最終都是調(diào)用message
success (options) {
return this.message('success', options);
}
2.message-->notice
message(type, options){
if (typeof options === 'string') {
options = {
content: options
};
}
return notice(options.content, options.duration, type, options.onClose, options.closable);
}
3.noitice-->getMessageInstance
function notice (content = '', duration = defaults.duration, type, onClose = function () {}, closable = false) {
//...
// 這個(gè)應(yīng)該是拿實(shí)例
let instance = getMessageInstance()
// 這個(gè)應(yīng)該是真正append到頁面上
instance.notice({
});
// 用于手動消除,返回值不用管
return (function () {
})();
}
4.getMessageInstance-->Notification.newInstance
function getMessageInstance () {
// 復(fù)用?
messageInstance = messageInstance || Notification.newInstance({
});
return messageInstance;
}
5.iview/src/components/base/notification/index.js
Notification.newInstance = properties => {
const _props = properties || {};
// 創(chuàng)建了一個(gè)統(tǒng)一v-for所有notice類的組件
const Instance = new Vue({
data: _props,
render (h) {
return h(Notification, {
props: _props
});
}
});
const component = Instance.$mount();
document.body.appendChild(component.$el);
return {
// 3里有調(diào)用notice()的一步
notice (noticeProps) {
// 調(diào)了組件的add,向v-for隊(duì)列里加了一個(gè),去notification.vue能看到
notification.add(noticeProps);
}
};北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
北大課工場是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。