myaijarvis
type: channel
link: http://www.myaijarvis.com/
description: 个人全栈程序员的博客网站，分享网站开发设计技术文章，以及网站开发日志等
items: 博客文章迁移
items: C++ 引用&&C语言二级指针（地址法理解）
items: C语言指针二（地址法理解）
items: C语言指针一（地址法理解）
items: typecho开启伪静态，去掉那个讨厌的index.php
items: HTML5+CSS+JS基础教程笔记
items: QT5入门精讲
items: Python用Pyspider爬取TripAdvisor的景点信息
items: Python用selenium爬取淘宝美食信息
items: Python分析Ajax请求抓取今日头条街拍美图

博客文章迁移
type: item
date: 2022-06-17T15:39:14+08:00
description: 博客文章迁移至CSDN，请各位看官移步查看！【参考：myaijarvis的博客_CSDN博客】主要内容：web前端（html、css、js、vue）Java后端（SpringBoot、Mybatis-Plus）数据结构与算法（Leetcode、蓝桥杯）机器学习（sklearn）自然语言处理（Pytorch）数据截至2022.6.17

C++ 引用&&C语言二级指针（地址法理解）
type: item
date: 2020-03-23T10:22:00+08:00
description: 普通变量#include <iostream> using namespace std; void swap(int &x, int &y) { //引用传递，可以理解为a就是x，x就是a，只不过名字不一样 cout << "函数内-start" << endl; cout << "&x:" << &x << " &y:" << &y << endl; cout << "x:" << x << " y:" << y << endl; cout << "开始交换" << endl; int tmp; tmp = x; x = y; y = tmp; cout << "&x:" << &x << " &y:" << &y << endl; cout << "x:" << x << " y:" << y << endl; cout << "函数内-end" << endl; } int main() { int a = 2, b = 3; cout << "before a:" << a << " b:" << b << endl; cout << "before &a:" << &a << " &b:" << &b << endl; swap(a, b); cout << "later a:" << a << " b:" << b << endl; cout << "later &a:" << &a << " &b:" << &b << endl; return 0; }结果before a:2 b:3 before &a:0x61fe1c &b:0x61fe18 函数内-start &x:0x61fe1c &y:0x61fe18 x:2 y:3 开始交换 &x:0x61fe1c &y:0x61fe18 x:3 y:2 函数内-end later a:3 b:2 later &a:0x61fe1c &b:0x61fe18指针变量#include <iostream> using namespace std; void swap(int *&x, int *&y) { cout << "函数内-start" << endl; cout << "&x:" << &x << " &y:" << &y << endl; cout << "x:" << x << " y:" << y << endl; cout << "开始交换" << endl; int *tmp;//x，y类型是int* tmp = x; x = y; y = tmp; cout << "&x:" << &x << " &y:" << &y << endl; cout << "x:" << x << " y:" << y << endl; cout << "函数内-end" << endl; cout<<endl; } int main() { int a = 2, b = 3; int *p=&a,*q=&b; cout << "before a:" << a << " b:" << b << endl; cout << "before &a:" << &a << " &b:" << &b << endl; cout << "before *p:" << *p << " &p:" << &p<<" p:"<<p<< endl; cout << "before *q:" << *q << " &q:" << &q<<" q:"<<q << endl; cout<<endl; swap(p, q); cout << "later a:" << a << " b:" << b << endl; cout << "later &a:" << &a << " &b:" << &b << endl; cout << "before *p:" << *p << " &p:" << &p<<" p:"<<p<< endl; cout << "before *q:" << *q << " &q:" << &q<<" q:"<<q << endl; return 0; }结果：before a:2 b:3 before &a:0x61fe1c &b:0x61fe18 before *p:2 &p:0x61fe10 p:0x61fe1c before *q:3 &q:0x61fe08 q:0x61fe18 函数内-start &x:0x61fe10 &y:0x61fe08 x:0x61fe1c y:0x61fe18 开始交换 &x:0x61fe10 &y:0x61fe08 x:0x61fe18 y:0x61fe1c 函数内-end later a:2 b:3 later &a:0x61fe…

C语言指针二（地址法理解）
type: item
date: 2020-03-22T21:36:00+08:00
description: 值传递和引用传递” 按值传递 “中包括值传递（实实在在的值啊！）和指针传递（指针传递参数本质上是值传递的方式，它所传递的是一个地址值），传递的都是实参的一个拷贝。#include <iostream> using namespace std; void swap(int x, int y) { int tmp; tmp = x; x = y; y = tmp; } int main() { int a = 2, b = 3; printf("before:%d,%d\n", a, b); swap(a, b); printf("later:%d,%d\n", a, b); return 0; }结果：before:2,3 later:2,3下面的例子体现了不论传递的是值还是指针 (指针也是一个值)，传递给被调用函数的都是实参的一个拷贝，直接对拷贝进行操作不会影响实参#include <iostream> using namespace std; void swap(int *x, int *y) { cout<<"函数内-start"<<endl; cout<<"*x:"<<*x<<" *y:"<<*y<<endl; cout<<"&x:"<<&x<<" &y:"<<&y<<endl; cout<<"x:"<<x<<" y:"<<y<<endl; cout<<"开始交换"<<endl; int *temp= NULL; //因为x，y的类型都是int * temp= x; //temp= &a &a:0x61fe1c &b:0x61fe18 x = y; // &a= &b y = temp; //&b=temp //所以交换x，y只是交换了两者存储的值(值为&a,&b)，并没有涉及到主函数a,b值的交换 //所以只是操作地址并没有卵用 cout<<"*x:"<<*x<<" *y:"<<*y<<endl; cout<<"&x:"<<&x<<" &y:"<<&y<<endl; cout<<"x:"<<x<<" y:"<<y<<endl; cout<<"函数内-end"<<endl; } int main() { int a = 2, b = 3; cout<<"before a:"<<a<<" b:"<<b<<endl; cout << "before &a:" << &a << " &b:" << &b << endl; swap(&a, &b); cout<<"later a:"<<a<<" b:"<<b<<endl; cout << "later &a:" << &a << " &b:" << &b << endl; return 0; }结果before a:2 b:3 before &a:0x61fe1c &b:0x61fe18 函数内-start *x:2 *y:3 //0x61fe1c->2,0x61fe18->3 &x:0x61fdf0 &y:0x61fdf8 x:0x61fe1c y:0x61fe18 开始交换 *x:3 *y:2 //0x61fe1c->2,0x61fe18->3 &x:0x61fdf0 &y:0x61fdf8 x:0x61fe18 y:0x61fe1c 函数内-end later a:2 b:3 later &a:0x61fe1c &b:0x61fe18#include <iostream> using namespace std; void swap(int *x, int *y) { cout<<"函数内-start"<<endl; cout<<"*x:"<<*x<<" *y:"<<*y<<endl; cout<<"&x:"<<&x<<" &y:"<<&y<<endl; cout<<"x:"<<x<<" y:"<<y<<endl; cout<<"开始交换"<<endl; int temp; //*x作用就是：取指针x的值(&a)，再把这个值作为地址，再取这个地址的值！相当于*(&a)=a temp= *x; //temp=a *x = *y; //a=b *y = temp; //b=temp cout<<"*x:"<<*x<<" *y:"<<*y<<endl; cout<<"&x:"<<&x<<" &y:"<<&y<<endl; cout<<"x:"<<x<<" y:"<<y<<endl; cout<<"函数内-end"<<endl; } int main() { int a = 2, b = 3; cout<<"before a:"<<a<<" b:"<<b<<endl; cout<<"before &a:"<<&a<<" &b:"<<&b<<endl; swap(&a, &b); …

C语言指针一（地址法理解）
type: item
date: 2020-03-22T20:58:00+08:00
description: 直接按例子来理解#include <iostream> using namespace std; int main() { int a=0; int *p; cout<<"*p:"<<*p<<" &p:"<<&p<<" p:"<<p<<endl; p=&a; cout<<"*p:"<<*p<<" &p:"<<&p<<" p:"<<p<<endl; cout<<"a:"<<a<<" &a:"<<&a<<endl; cout<<endl; //*p作用就是：取指针p的值，再把这个值作为地址，再取这个地址的值！相当于*(&a)=a *p=*p+1; //相当于a=a+1 cout<<"*p:"<<*p<<" &p:"<<&p<<" p:"<<p<<endl; cout<<"a:"<<a<<" &a:"<<&a<<endl; cout<<endl; p=p+1; //相当于在p的值中加了一个int类型的大小存储单元，就是加4：&a+4 cout<<"*p:"<<*p<<" &p:"<<&p<<" p:"<<p<<endl; cout<<"a:"<<a<<" &a:"<<&a<<endl; }结果*p:1513105 &p:0x61fe10 p:0x1716e0 *p:0 &p:0x61fe10 p:0x61fe1c a:0 &a:0x61fe1c *p:1 &p:0x61fe10 p:0x61fe1c a:1 &a:0x61fe1c *p:15210176 &p:0x61fe10 p:0x61fe20 //这里十六进制 1c+4=20 a:1 &a:0x61fe1c解析

typecho开启伪静态，去掉那个讨厌的index.php
type: item
date: 2020-03-16T14:23:59+08:00
description: Typecho后台设置永久链接后，会在域名后加上index.php，很多人都接受不了。例如如下网址：http://qqdie.com/index.php/archives/37/，但我们希望最终的形式是这样：http://qqdie.com/archives/37.html。那么我们如何做到这样的效果？1.配置服务器的rewrite规则如果在保存上述配置的时候，typecho无法自动配置，那么你可能需要手动配置服务器的rewrite规则。Linux Apache 环境 (.htaccess)：<IfModule mod_rewrite.c> RewriteEngine On # 下面是在根目录，文件夹要修改路径 RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] </IfModule>Linux Apache 环境（Nginx）：location / { index index.html index.php; if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php) { rewrite (.*) $1/index.php; } if (!-f $request_filename) { rewrite (.*) /index.php; } }Windows IIS 伪静态 (httpd.ini)：[ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 # 中文tag解决 RewriteRule /tag/(.*) /index\.php\?tag=$1 # sitemapxml RewriteRule /sitemap.xml /sitemap.xml [L] RewriteRule /favicon.ico /favicon.ico [L] # 内容页 RewriteRule /(.*).html /index.php/$1.html [L] # 评论 RewriteRule /(.*)/comment /index.php/$1/comment [L] # 分类页 RewriteRule /category/(.*) /index.php/category/$1 [L] # 分页 RewriteRule /page/(.*) /index.php/page/$1 [L] # 搜索页 RewriteRule /search/(.*) /index.php/search/$1 [L] # feed RewriteRule /feed/(.*) /index.php/feed/$1 [L] # 日期归档 RewriteRule /2(.*) /index.php/2$1 [L] # 上传图片等 RewriteRule /action(.*) /index.php/action$1 [L]nginx 配置server { listen 80; server_name yourdomain.com; root /home/yourdomain/www/; index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; } location ~ .*\.php(\/.*)*$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } access_log logs/yourdomain.log combined; }apache 配置<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] </IfModule>2.后台配置typecho伪静态在typecho后台，开启伪静态，并选择你喜好的url形式即可。本文来源：https://qqdie.com/archives/typecho-open-pseudo-static-get-ri…

HTML5+CSS+JS基础教程笔记
type: item
date: 2020-03-16T09:56:00+08:00
description: HTML5靠谱教程合集，HTML5+CSS+JS全方面解析，附上节课回顾word文档帮助记忆，最新最全的HTML5教程传送门:点我 ps:图片未经压缩，网络不通畅可能加载比较慢，请耐心等待一会！

QT5入门精讲
type: item
date: 2020-03-16T09:51:00+08:00
description: QT5入门精讲系列（来自于吴健老师）（ps：一个很精彩的QT入门教程！）传送门:点我非常好的从c++过渡到Qt的入门视频，对Qt的大部分基础元素有着非常通俗、全面的讲解。基础篇 案例篇计算器 管理系统 打地鼠 Qt常用快捷键

Python用Pyspider爬取TripAdvisor的景点信息
type: item
date: 2020-03-10T13:17:00+08:00
description: 先上效果图上代码：from pyspider.libs.base_handler import * import pymongo class Handler(BaseHandler): crawl_config = { } client = pymongo.MongoClient('localhost') db = client['TripAdvise'] @every(minutes=24 * 60) def on_start(self): self.crawl('https://www.tripadvisor.cn/Attractions-g186338-Activities-c47-London_England.html',callback=self.index_page, validate_cert=False) @config(age=10 * 24 * 60 * 60) def index_page(self, response): for each in response.doc('div.listing_title > a').items(): self.crawl(each.attr.href, callback=self.detail_page, validate_cert=False) # 翻页 next = response.doc('.pagination .nav.next').attr.href self.crawl(next, callback=self.index_page, validate_cert=False) @config(priority=2) def detail_page(self, response): url = response.url name = response.doc('.h1').text() rating = response.doc(' div.ratingContainer > a > span').text() garde = response.doc('div.section.rating > span').text() address = response.doc('.contactInfo > .address').text() phone = response.doc('div.contact > div.contactType.phone.is-hidden-mobile > div').text() opening = response.doc('div.prw_rup.prw_common_atf_header_bl_responsive.headerBL > div > span').text() introduction = response.doc('.centerWell > div > div > div > div > div > span').text() return { "url": url, "name": name, "rating": rating, 'garde': garde, "address": address, "phone": phone, "opening": opening, "introduction": introduction } def on_result(self, result): if result: self.save_to_mongo(result) def save_to_mongo(self, result): if self.db['london'].insert(result): print('保存到MongoDB成功', result)参考：https://cuiqingcai.com/8317.html

Python用selenium爬取淘宝美食信息
type: item
date: 2020-03-09T11:32:00+08:00
description: 先奉上代码：# 如果使用PhantomJS则selenium版本只能2.48.0及以下 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import time import re from pyquery import PyQuery as py import pymongo MONGO_URL='localhost' MONGO_DB='taobao' MONGO_TABLE='product' SERVICE_ARGS=['--load-images=false','--disk-cache=true'] # 不加载图片，开启缓存 client = pymongo.MongoClient(MONGO_URL, connect=False) db=client[MONGO_DB] # browser = webdriver.Chrome() browser = webdriver.PhantomJS(service_args=SERVICE_ARGS) browser.set_window_size(1400,900) #设置窗口大小，防止元素位置改变 wait = WebDriverWait(browser, 15) def search(): # 执行搜索后跳转到登录界面--选择微博登录-（淘宝要绑定微博，微博登录要取消双重登录验证） try: browser.get("https://www.taobao.com/") print('正在搜索') input = wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#q")) ) # 输入框 submit = wait.until( EC.element_to_be_clickable((By.CSS_SELECTOR, "#J_TSearchForm > div.search-button > button")) ) # 搜索按钮 input.send_keys('美食') time.sleep(1) submit.click() # 登录 print('正在登录') wait.until( EC.element_to_be_clickable((By.CSS_SELECTOR, "#J_Quick2Static")) ).click() # 点击密码登录 time.sleep(2) wait.until( EC.element_to_be_clickable((By.CSS_SELECTOR, "#J_OtherLogin > a.weibo-login")) ).click() # 选择微博登录 wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#pl_login_logged > div > div:nth-child(2) > div > input")) ).send_keys(' ') # 输入账号 time.sleep(2) wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#pl_login_logged > div > div:nth-child(3) > div > input")) ).send_keys(' ') # 输入密码 time.sleep(2) wait.until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "#pl_login_logged > div > div:nth-child(7) > div:nth-child(1) > a > span")) ).click() # 点击登录按钮 time.sleep(5) total = wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#mainsrp-pager > div > div > div > div.total")) ) print('登录成功') get_prodects() return total.text except TimeoutError: search() # 翻页 def ne…

Python分析Ajax请求抓取今日头条街拍美图
type: item
date: 2020-03-08T14:29:22+08:00
description: 结果如下：程序运行结果"C:\Program Files\Python\Python38\python.exe" E:/PycharmProjects/test/爬虫/今日头条街拍/Spider.py 请求文章详情页出错 None 正在下载1d47b4dceb635bff92ef296ce530cdc2.jpg 正在下载bff2d27b1d4ed77cc0a575513b9eeea4.jpg 正在下载f30c57b85c75fe655612450c993b320b.jpg 正在下载2475f2ad97bdcb6a45e6d64ce1650ca6.jpg 正在下载52fc1cd305b52366532f3ec7a9729a71.jpg 正在下载dc59cae9ed2859454c461b2944b819b1.jpg 正在下载bf1b48c4ca5cfeffec3bee95b1da6b64.jpg 正在下载7b8c8a28c037eac669988e34e90e37de.jpg 正在下载ad0fb9dbfcc0f15981fd701339e13bb8.jpg 正在下载98486366369a8c0b79f4c6ced3fb51b0.jpg E:/PycharmProjects/test/爬虫/今日头条街拍/Spider.py:125: DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead. if db[MONGO_TABLE].insert(result): 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6760980286252515853/', 'title': '三里屯街拍', 'images': ['http://p9.pstatp.com/origin/pgc-image/f23cd60127824cb88b11256cf9ffe951', 'http://p9.pstatp.com/origin/pgc-image/0c54ffb46fdd4553ad99e9273a85643f', 'http://p9.pstatp.com/origin/pgc-image/da0dd5a6d8314f699de340c06a9093ec', 'http://p3.pstatp.com/origin/pgc-image/7fff7dff1863466883d0920481bc9ffe', 'http://p1.pstatp.com/origin/pgc-image/9ddcb34586514ab7ad6427c73c416f51', 'http://p3.pstatp.com/origin/pgc-image/a406850542ca496aa1f68333e42aea87', 'http://p1.pstatp.com/origin/pgc-image/50bb8781363e4e3e8e9e45137ded07f6', 'http://p3.pstatp.com/origin/pgc-image/6dfc140a4d814cd49295f210aa1499bd', 'http://p1.pstatp.com/origin/pgc-image/014679ab63584e0ca7f8612b8b120651', 'http://p9.pstatp.com/origin/pgc-image/be0226872a864d2aac76c28987938cdf'], '_id': ObjectId('5e648f564d5a25526d8630e9')} 请求文章详情页出错 None 正在下载289d58776687584857ea8d2cec8e3266.jpg 正在下载4d89bd5efc7166322207e31e737cd6d2.jpg 正在下载bcfd11725613120a2f6f20145521bf70.jpg 正在下载2256eed522bab696d578be7bd021a79d.jpg 正在下载9f4b6fac29acae9d0d3964a33922cd76.jpg 正在下载6226b26aacb6111fa5bb6ab4ecb360ca.jpg 正在下载22e469ecf6277bf6631e9053b0782656.jpg 正在下载fb6e9bba0afd3880fd5acb418c08af06.jpg 正在下载9e418d8f5aa93beefe64005a941b0b8d.jpg 正在下载dc98a060a3ee9abe1583bc304de1dfd1.jpg…