Leverage statistical trends like pass accuracy or possession percentages to predict match outcomes accurately.
wangxiaoxiao123/Python/python爬虫/知乎.py
# -*- coding:utf8 -*-
import time
import random
import requests
from bs4 import BeautifulSoup
def get_answer(question_id):
answer = []
url = ‘https://www.zhihu.com/api/v4/questions/’ + question_id + ‘/answers?sort_by=default&include=content&offset=0&limit=5’
headers = {
‘Host’: ‘www.zhihu.com’,
‘User-Agent’: ‘Mozilla/5.0 (Windows NT x.y; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987 Safari/537.36’,
‘Referer’: ‘https://www.zhihu.com/’,
‘Accept-Encoding’: ‘gzip’,
‘Cookie’: ‘__utma=30149280.1104621659.1540444977.’
‘1540444977.; _zap=c6c442b9-cf94-ea43-aed8-bd6a940b6e03;’
‘__utmc=30149280; d_c0=”AGDwMwP9jOQAAAAiZkPmWqXKqYRdUOeWQ==”; ‘
‘__utmz=30149280.1540444977..1.1.’
‘.utm_source:toutiao&utm_medium=weibo_android_share’
‘; z_c0=”229498672|1530708099|”
‘NaHRscF9ldmlkZW8%253DODA%252CMTIwMCZzaWdtYXA%253DMSZzaWdubGluaxQlMkYxJnNpdnR4X21haWxjb250ZW50X25ldHdvcmsmcHJlbWl1bV9pbml0PTEwJnByZW1pdW1fdmlld19pbml0PTEmcHJlbWl1bV90aGVtZXNfcGFnZXM9MiZzaXRlX21wdGlvbnMmcGFzc3dkPUBxLmNvbnRlbnQuemlsbHVzLmNvbSZhbWMxcDA9MXgweDBfMWEmYjEzMjA4MDAwMDAwMDAwMzYmYjEzMjA4MDAwMDAwMDAxMTMmNDI5OTM5NjUyNTU=’;
‘_xsrf=hxei14s6r85pfy76sffoobvpkqg45z09’
}
r = requests.get(url=url,
headers=headers)
json_data = r.json()
print(json_data[‘paging’][‘is_end’])
if json_data[‘paging’][‘is_end’] == False:
total_page = json_data[‘paging’][‘totals’]
page_count = int(total_page / json_data[‘paging’][‘size’]) +
int(total_page % json_data[‘paging’][‘size’]) / json_data[‘paging’][‘size’]
print(page_count)
for i in range(0,int(page_count)):
url_temp = url.replace(‘offset=0’, ‘offset=’+str(i*json_data[‘paging’][‘size’]))
r_temp = requests.get(url=url_temp,
headers=headers)
json_temp = r_temp.json()
print(json_temp)
if len(json_temp) !=0:
answer.extend(json_temp)
time.sleep(random.randint(1,4))
return answer
def get_answer_content(answer):
content_list=[]
title_list=[]
author_list=[]
# url_answer=’https://www.zhihu.com/question/’+question_id+’/answer/’+str(answer_id)
# html_answer=requests.get(url_answer).text
# soup_answer=BeautifulSoup(html_answer,’html.parser’)
# title=soup_answer.find_all(‘div’,class_=’QuestionHeader-title’)[0].find_all(‘span’)[0].string.strip()
# author=soup_answer.find_all(‘a’,class_=’author-link’)[0].string.strip()
# content=soup_answer.find_all(‘div’,class_=’RichContent-inner’)[0].find_all(‘div’)[1]
# content=str(content).replace(‘
‘,’n’).replace(‘
‘,”).replace(‘
n’,”).replace(‘<img src="//','<img src="https://').replace('/s.qlogo.cn/baike/w100/', '/upload/')
# print(title+'n'+author+'n'+content)
# content_list.append(content)
# title_list.append(title)
# author_list.append(author)
if __name__ == '__main__':
<|file_sep
from flask import Flask,jsonify,request
import sys
sys.path.append('../')
from common import *
from process import *
app = Flask(__name__)
@app.route('/api/getRecommendationList',methods=['GET'])
def getRecommendationList():
"""
:param page :page number
:param size :number per page
:return :list of recommendation information
"""
page=int(request.args.get('page'))
size=int(request.args.get('size'))
recommendations=get_recommendations(page,size)
return jsonify(recommendations)
@app.route('/api/getRecommendationDetail/’,methods=[‘GET’])
def getRecommendationDetail(recommendationId):
“””
:param recommendationId :id of recommendation
:return :detail information about recommendation
“””
recommendation=get_recommendation_detail(recommendationId)
return jsonify(recommendation)
@app.route(‘/api/searchRecommendations’,methods=[‘POST’])
def searchRecommendations():
“””
:param keyword :keyword used for searching
:param page :page number
:param size :number per page
:return list of recommendations based on keyword search
“””
data=request.get_json()
keywords=data[‘keywords’]
page=data[‘page’]
size=data[‘size’]
recommendations=search_recommendations(keywords,size,size*(page-1))
return jsonify(recommendations)
if __name__==’__main__’:
app.run(host=’127.0.01′,port=’5005′)wangxiaoxiao123/Python<|file_sep/users.sql
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`user_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(255),
`password` VARCHAR(255),
`email` VARCHAR(255),
`phone_number` VARCHAR(255),
`address` VARCHAR(255),
`sns_account_type` ENUM("QQ","WEIBO","WECHAT"),
`sns_account_number` VARCHAR(255),
`sns_openid` VARCHAR(255),
`sns_access_token_expires_in` DATETIME,
`sns_access_token_refresh_expires_in DATETIME`,
`sns_access_token_expires_at DATETIME`,
`sns_access_token_refresh_expires_at DATETIME`,
`sns_access_token TEXT`
) ENGINE=InnoDB DEFAULT CHARSET=utf8;<|file_sep[TOC]
## 静态网站搭建流程
### 前期准备工作
#### 安装Git
在[git的官网](http://git-scm.com/)下载对应的版本,安装即可。
#### 注册Github账号并创建仓库
进入[Github](https://github.com/),注册账号。然后创建一个仓库,命名为你自己的名字加上.github.io。例如:myname.github.io。
### 搭建本地环境和本地仓库
#### 安装Hexo(静态博客生成器)
npm install hexo-cli -g //全局安装hexo-cli工具包
如果出现如下错误:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.1.
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.
可以忽略,因为这个模块是用来实现文件系统监控的,在windows上没有必要安装。
#### 初始化项目目录
在电脑任意位置新建一个文件夹,并初始化一个hexo项目(注意:此处路径不能有中文)
hexo init [文件夹名称] //初始化项目目录,会自动下载相关模块和配置文件到该目录下。
#### 编辑配置文件_config.yml_
打开该文件,修改如下内容:
yaml
deploy:
type: git //部署方式选择git。
repository: https://github.com/[你的用户名]/[你的用户名].github.io.git//填写你在github上创建好的仓库地址。
branch: master//分支选择master分支。
message:"[发布信息]"//发布信息随便填。
#### 安装插件hexo-deployer-git(部署插件)
shell script
npm install hexo-deployer-git –save //安装插件并保存到package.json中。
#### 创建第一篇文章(可选)
在根目录下执行:
shell script
hexo new post "[文章标题]"
会自动生成一个md格式的文章框架,在根目录下的source/_posts文件夹下。可以修改或者添加内容。
### 部署到Github上面
首先要将本地仓库与远程仓库关联起来。在根目录下执行:
shell script
git init //初始化本地仓库。
git add . //添加所有未提交过的改动。
git commit -m "[提交信息]"//提交改动,并添加注释说明。
git remote add origin https://github.com/[你的用户名]/[你的用户名].github.io.git//关联远程仓库。
git push -u origin master //将本地仓库推送到远程仓库上面去。(第一次需要使用-u参数)
完成以上步骤之后,再次执行以下命令就不需要-u参数了。
shell script
hexo clean && hexo g && hexo d //清除缓存、生成静态页面、部署到远程服务器。
此时访问http://[你的用户名].github.io就能看到已经发布上去了。
### 后续更新文章步骤
每次更新文章之后都要执行以下步骤才能生效:
shell script
hexo clean && hexo g && hexo d //清除缓存、生成静态页面、部署到远程服务器。
## 配置主题样式及功能性插件(可选)
如果对默认主题不满意,可以更换其他主题。更多主题参考:[Hexo官方主题](https://hexoblog.github.io/themes/)。
更换主题方式如下:
首先找到喜欢的主题,并复制其地址。例如我使用了[Cactus](https://github.com/probberechts/hexo-theme-cactus)主题,则复制其地址为:https://github.com/probberechts/hexo-theme-cactus.git。
然后在根目录下执行以下命令将其clone到themes目录下:
shell script
cd themes && git clone https://github.com/probberechts/hexo-theme-cactus.git cactus && cd ..
接着编辑_config.yml文件,在theme项中修改为刚刚下载好的主题名称即可(注意大小写):
yaml theme:cactus//
最后再次执行以下命令即可看到新样式生效:
shell script hexo clean && hexo g && hexo d //
至于其他功能性插件可以参考各个主题文档进行配置。比如我的博客中使用了代码高亮插件highlight.js和图标字体Font Awesome等等。wangxiaoxiao123/Python100:
content+=”…”
content+=”…”*int(len(content)/100)
print(title+author+content)
continuennnnnnnnnnnnnnn”
else:
print(“无法访问,请检查输入是否正确”)
wangxiaoxiao123/Python<|file_sep#!/usr/bin/env python
#!coding:utf8
'''
@author:Xiaoxiao Wang
@contact:[email protected]
@file:get_user_info.py
@time:
'''
"""
Get user info from ZhiHu.
"""
import requests
from lxml import etree
class ZhiHu():
def __init__(self):
def getUserInfo(self):
if __name__ == "__main__":
pass
"""
Example:
"""
"""
References:
"""
wangxiaoxiao123/Python<|file_sep'.vuepress/config.js'
module.exports = {
title:"小晴の博客",
description:"记录成长点滴",
base:'/blog/',
dest:'public',
head:[
['link',{rel:'icon',href:'./logo.png'}],
['meta',{name:'viewport','content':'width=device-width,user-scalable=no'}],
['meta',{name:'apple-mobile-web-app-capable',"content":"yes"}],
['meta',{name:'apple-mobile-web-app-status-bar-style',"content":"black-translucent"}],
['meta',{name:'format-detection',"content":"telephone=no"}],
['meta',{name:'keywords',"content":"小晴の博客,Xiaoxiang,Wang Xiaoxiao"}]
],
logos:"./logo.png",
pagesDir:"pages",
pagesConfig:{
"/index.html":{
title:"首页",
keywords:"小晴の博客,Xiaoxiang,Wang Xiaoxiao"
},
"/about.html":{
title:"关于我",
keywords:"小晴の博客,Xiaoxiang,Wang Xiaoxiao"
},
"/archives.html":{
title:"归档",
keywords:"小晴の博客,Xiaoxiang,Wang Xiaoxiao"
},
"/tags.html":{
title:"标签",
keywords:"小晴の博客,Xiaoxiang,Wang Xiaoxiao"
},
"/categories.html":{
title:"分类",
keywords:"小晴の博客,Xiaoxiang,Wang Xiaoxiao"
}
},
themeConfig:{
sidebarDepth:3,
sidebar:[
'/',
'/about',
'/archives',
'/tags',
'/categories'
],
footbar:[
{
text:'Copyright ©2020 小晴の博客 All Rights Reserved.',
link:'/about'
}
]
},
plugins:[
[ '@vuepress/back-to-top'],
["sitemap",{
hostname:"",
path:'/sitemap.xml',
}],
["sitemap",{
hostname:"",
path:'/search.xml'
}]
]
}wangxiaoxiao123/Python<|file_sep– MySQL dump 10.13 Distrib 8.0.17, for Win64 (x86_64)
—
— Host: localhost Database: mydb
— ——————————————————
— Server version 8.0.17
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
—
— Table structure for table `articles`
—
DROP TABLE IF EXISTS `articles`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `articles`
(
`article_id`
int unsigned auto_increment primary key,
article_title varchar(128),
article_content text,
article_summary text,
article_author varchar(32),
article_create_time datetime,
article_update_time datetime,
recommend_tag varchar(16),
tag varchar(16)
);
—
— Dumping data for table `articles`
—
LOCK TABLES `articles` WRITE;
UNLOCK TABLES;
—
— Table structure for table `comments`
—
DROP TABLE IF EXISTS `comments`;
CREATE TABLE comments (
comment_ID int unsigned auto_increment primary key,
comment_article_ID int unsigned not null,
comment_parent_ID int unsigned default null,
comment_author varchar(32),
comment_email varchar(32),
comment_author_url varchar(128),
comment_date datetime,
comment_ip_address varchar(15),
comment_content text,
foreign key(comment_article_ID) references articles(article_ID),
foreign key(comment_parent_ID) references comments(comment_ID)
);
—
— Dumping data for table `comments`
—
LOCK TABLES comments WRITE;
UNLOCK TABLES;
—
— Table structure for table `users`
—
DROP TABLE IF EXISTS users;
CREATE TABLE users (
user_ID int unsigned auto_increment primary key,
username varchar(32),
password char (60), — use sha256 hash algorithm
email varchar (32),
phone_number varchar (20),
address varchar (256),
sns_account_type enum ("QQ","WEIBO","WECHAT"),
sns_account_number varchar (128),
sns_openid char (128), — openid from SNS platform
sns_access_token_expires_in datetime,
sns_access_token_refresh_expires_in datetime,
sns_access_token_expires_at datetime,
sns_access_token_refresh_expires_at datetime,
sns_access_token text — access token from SNS platform.
);
—
— Dumping data for table `users`
—
LOCK TABLES users WRITE;
UNLOCK TABLES;
/*Table structure message*/
DROP TABLE IF EXISTS message;
CREATE TABLE message (
message_ID int unsigned auto_increment primary key,
message_sender_ID int unsigned not null,
message_receiver_ID int unsigned not null,
message_send_time datetime,
message_read_state bool default false,
message_content text,
foreign key(message_sender_ID) references users(user_ID),
foreign key(message_receiver_ID) references users(user_ID)
);
/*Table structure notification*/
DROP TABLE IF EXISTS notification;
CREATE TABLE notification (
notification_ID int unsigned auto_increment primary key,
notification_receiver_userID int unsigned not null,
notification_send_userID int unsigned not null,
notification_send_time datetime default now(),
notification_read_state bool default false,
notification_message text,
foreign key(notification_receiver_userID) references users(user_ID),
foreign key(notification_send_userID) references users(user_ID)
);
/*Table structure friend*/
DROP TABLE IF EXISTS friend;
CREATE table friend(
friendship_status enum ("request_sent","request_received","friends"),
friendship_application_time datetime default now(),
friendship_last_updated_time datetime default now(),
user_A_userID int unsigned not null ,
user_B_userID int unsigned not null ,
primary key(user_A_userID,user_B_userID), /*composite primary keys*/
foreign key(user_A_userID ) references users(user_Id ), /*composite foreign keys*/
foreign key(user_B_userID ) references users(user_Id )
);
/*Table structure follow*/
DROP TABLE IF EXISTS follow;
create table follow(
follow_status enum ("following","follower"), /*whether following each other*/
follow_application_time datetime default now(), /*when start following each other*/
follow_last_updated_time datetime default now(), /*last updated time*/
user_A_userID int unsigned not null ,
user_B_userID int unsigned not null ,
primary key(user_A_userID,user_B_userID), /*composite primary keys*/
foreign key(user_A_userID ) references users(user_Id ), /*composite foreign keys*/
foreign key(user_B_userID ) references users(user_Id )
);
/*Table structure favorite*/
DROP Table IF EXISTS favorite;
create table favorite(
favorite_addition_time datetime default now(), /*when add favorite*/
favorite_last_updated_time datetime default now(), /*last updated time*/
favorite_article article_int(unsigned )not null ,
favorite_reader user_int(unsigned )not null ,
primary_key(favorite_article,favorite_reader),/*composite primary keys*/
foreign_key(favorite_article )references articles(article_Id ),/*composite foreign keys*/
foreign_key(favorite_reader )references user(Id )
);
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT;
SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS;
SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;
SET TIME_ZONE=@OLD_TIME_ZONE;wangxiaoxiao123/Python<|file_sepupyter notebook –no-browser –port=$PORT –ip=$IPbject_t * ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast(offsetof(CloseReason_t104838859C933D83BACCEB45C82CAE06F531FAF08_StaticFields, ___value___2)); }
inline uint16_t get_value___2() const { return ___value___2; }
inline uint16_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(uint16_t value)
{
___value___2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CLOSEREASON_T104838859C933D83BACCEB45C82CAE06F531FAF08_H
#ifndef CUSTOMATTRIBUTENAMEDARGUMENT_T98CF62CCA07CBFD95BB70ED4FFAB20046