首页 文章 精选 留言 我的

精选列表

搜索[web],共10000篇文章
优秀的个人博客,低调大师

SAP BSP, Java Web Project,Android和微信小程序的初始页面设置

CRM Webclient UI Component controller的context DO_INIT_CONTEXT: 然后是Window controller的DO_INIT_CONTEXT: 最后才是view controller的DO_INIT_CONTEXT: Android 微信小程序 (1) onLoad 生命周期函数--监听页面加载(2) onReady 生命周期函数--监听页面初次渲染完成(3) onShow 生命周期函数--监听页面显示(4) onHide 生命周期函数--监听页面隐藏(5) onUnload 生命周期函数--监听页面卸载 打开小程序后会依次执行onLoad,onReady和onShow方法. 前后台切换会分别执行onHide和onShow方法 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

优秀的个人博客,低调大师

6、web爬虫讲解2—urllib库爬虫—基础使用—超时设置—自动模拟http请求

利用python系统自带的urllib库写简单爬虫 urlopen()获取一个URL的html源码read()读出html源码内容decode("utf-8")将字节转化成字符串 #!/usr/bin/env python # -*- coding:utf-8 -*- import urllib.request html = urllib.request.urlopen('http://edu.51cto.com/course/8360.html').read().decode("utf-8") print(html) <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="csrf-param" content="_csrf"> <meta name="csrf-token" content="X1pZZnpKWnQAIGkLFisPFT4jLlJNIWMHHWM6HBBnbiwPbz4/LH1pWQ=="> 正则获取页面指定内容 #!/usr/bin/env python # -*- coding:utf-8 -*- import urllib.request import re html = urllib.request.urlopen('http://edu.51cto.com/course/8360.html').read().decode("utf-8") #获取html源码 pat = "51CTO学院Python实战群\((\d*?)\)" #正则规则,获取到QQ号 rst = re.compile(pat).findall(html) print(rst) #['325935753'] urlretrieve()将网络文件下载保存到本地,参数1网络文件URL,参数2保存路径 #!/usr/bin/env python # -*- coding:utf-8 -*- from urllib import request import re import os file_path = os.path.join(os.getcwd() + '/222.html') #拼接文件保存路径 # print(file_path) request.urlretrieve('http://edu.51cto.com/course/8360.html', file_path) #下载这个文件保存到指定路径 urlcleanup()清除爬虫产生的内存 #!/usr/bin/env python # -*- coding:utf-8 -*- from urllib import request import re import os file_path = os.path.join(os.getcwd() + '/222.html') #拼接文件保存路径 # print(file_path) request.urlretrieve('http://edu.51cto.com/course/8360.html', file_path) #下载这个文件保存到指定路径 request.urlcleanup() info()查看抓取页面的简介 #!/usr/bin/env python # -*- coding:utf-8 -*- import urllib.request import re html = urllib.request.urlopen('http://edu.51cto.com/course/8360.html') #获取html源码 a = html.info() print(a) # C:\Users\admin\AppData\Local\Programs\Python\Python35\python.exe H:/py/15/chshi.py # Date: Tue, 25 Jul 2017 16:08:17 GMT # Content-Type: text/html; charset=UTF-8 # Transfer-Encoding: chunked # Connection: close # Set-Cookie: aliyungf_tc=AQAAALB8CzAikwwA9aReq63oa31pNIez; Path=/; HttpOnly # Server: Tengine # Vary: Accept-Encoding # Vary: Accept-Encoding # Vary: Accept-Encoding getcode()获取状态码 #!/usr/bin/env python # -*- coding:utf-8 -*- import urllib.request import re html = urllib.request.urlopen('http://edu.51cto.com/course/8360.html') #获取html源码 a = html.getcode() #获取状态码 print(a) #200 geturl()获取当前抓取页面的URL #!/usr/bin/env python # -*- coding:utf-8 -*- import urllib.request import re html = urllib.request.urlopen('http://edu.51cto.com/course/8360.html') #获取html源码 a = html.geturl() #获取当前抓取页面的URL print(a) #http://edu.51cto.com/course/8360.html timeout抓取超时设置,单位为秒 是指抓取一个页面时对方服务器响应太慢,或者很久没响应,设置一个超时时间,超过超时时间就不抓取了 #!/usr/bin/env python # -*- coding:utf-8 -*- import urllib.request import re html = urllib.request.urlopen('http://edu.51cto.com/course/8360.html',timeout=30) #获取html源码 a = html.geturl() #获取当前抓取页面的URL print(a) #http://edu.51cto.com/course/8360.html 自动模拟http请求 http请求一般常用的就是get请求和post请求 get请求 比如360搜索,就是通过get请求并且将用户的搜索关键词传入到服务器获取数据的 所以我们可以模拟百度http请求,构造关键词自动请求 quote()将关键词转码成浏览器认识的字符,默认网站不能是中文 #!/usr/bin/env python # -*- coding: utf-8 -*- import urllib.request import re gjc = "手机" #设置关键词 gjc = urllib.request.quote(gjc) #将关键词转码成浏览器认识的字符,默认网站不能是中文 url = "https://www.so.com/s?q="+gjc #构造url地址 # print(url) html = urllib.request.urlopen(url).read().decode("utf-8") #获取html源码 pat = "(\w*<em>\w*</em>\w*)" #正则获取相关标题 rst = re.compile(pat).findall(html) # print(rst) for i in rst: print(i) #循环出获取的标题 # 官网 < em > 手机 < / em > # 官网 < em > 手机 < / em > # 官网 < em > 手机 < / em > 这么低的价格 # 大牌 < em > 手机 < / em > 低价抢 # < em > 手机 < / em > # 淘宝网推荐 < em > 手机 < / em > # < em > 手机 < / em > # < em > 手机 < / em > # < em > 手机 < / em > # < em > 手机 < / em > # 苏宁易购买 < em > 手机 < / em > # 买 < em > 手机 < / em > # 买 < em > 手机 < / em > post请求 urlencode()封装post请求提交的表单数据,参数是字典形式的键值对表单数据Request()提交post请求,参数1是url地址,参数2是封装的表单数据 #!/usr/bin/env python # -*- coding: utf-8 -*- import urllib.request import urllib.parse posturl = "http://www.iqianyue.com/mypost/" shuju = urllib.parse.urlencode({ #urlencode()封装post请求提交的表单数据,参数是字典形式的键值对表单数据 'name': '123', 'pass': '456' }).encode('utf-8') req = urllib.request.Request(posturl,shuju) #Request()提交post请求,参数1是url地址,参数2是封装的表单数据 html = urllib.request.urlopen(req).read().decode("utf-8") #获取post请求返回的页面 print(html) 【转载自:http://www.lqkweb.com】

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册
修改密码
忘记密码