url

Why does this URL do different things depending on how it's activated?

ⅰ亾dé卋堺 提交于 2020-01-24 20:54:06
问题 In a related post (here) I discuss a problem I'm having with a URL action in a SQL Server Reporting Services report. I thought I had solved the problem, but I now realize that I haven't. (I'll update the related post in due course.) I'm generating a URL using string concatenation, and using Javascript so the URL opens in a new browser tab. Here's the code that generates the URL, which I think is pretty standard: ="javascript:void(window.open('http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch

selenium复习-python(一)

邮差的信 提交于 2020-01-24 18:04:23
简单使用实例: from selenium import webdriver import time #模拟创建浏览器对象,通过对象操作浏览器 path = 'F://chromedriver' #驱动路径,可根据不同的浏览器及其版本选择下载 driver = webdriver.Chrome(executable_path = path) # 构建一个谷歌浏览器对象 url = 'http://www.baidu.com' #要访问的url地址 driver.get(url) # 访问该url time.sleep(3) # 延时 # 定位搜索关键词 my_input = driver.find_element_by_id('kw') #输入搜索内容 my_input.send_keys("长恨歌") #定位搜索按钮 button = driver.find_element_by_class_name('s_btn') button.click() # 点击事件 image = driver.find_elements_by_class_name('op-img-address-link-imgs') time.sleep(3) #退出浏览器 driver.quit() selenium常用定位方式: find_elements_by_id() 根据id查找节点 find

Python requests库的基础使用

ε祈祈猫儿з 提交于 2020-01-24 18:02:06
简单介绍 requests库简单易用的HTTP库    Get请求 格式: requests.get(url) 注意: 若需要传请求参数,可直接在 url 最后的 ? 后面,也可以调用 get() 时多加一个参数 params ,传入请求参数,注意需要是 dict 格式;如下图所示 1 url = 'http://127.0.0.1:8888/passport/user/login' 2 param = { 3 'username': '123', 4 'password': '321' 5 } 6 7 """通过params传参""" 8 res = requests.get(url, params=param) 9 # {'code': 200, 'msg': 'success', 'password': '321', 'username': '123'} 10 print(res.json()) 11 12 """通过params方式传参,最终发出的url也是一致的""" 13 # http://127.0.0.1:8888/passport/user/login?username=123&password=321 14 print(res.url) 15 16 """通过url最后加上请求参数列表""" 17 url = 'http://127.0.0.1:8888

python接口自动化测试(二)-requests.get()

此生再无相见时 提交于 2020-01-24 17:09:07
环境搭建好后,接下来我们先来了解一下 requests 的一些简单使用,主要包括: requests常用请求方法使用,包括:get,post requests库中的Session、Cookie的使用 其它高级部分:认证、代理、证书验证、超时配置、错误异常处理等。 本节首先来了解一下requests库中如何发送get请求: 一、看下方法定义: 1、到 官方文档 去了下requests.get()方法的定义,如下: 2、点击右上角的【source】,看一下它的源码如下: 看到最后一行return,get方法最后是通过调用 requests.request 方法实现的,其实在其它的请求方法如post,put,head,delete等方法都是调用的request方法,然后把请求方法的类型传递给request方法第一个参数。 3、HTTP协议 是一个基于请求/响应模式的、无状态的,应用层协议。既然有请求,就有响应,来看下resquest中 常用的响应信息: 二、get方法简单使用: 1、不带参数的get: # -*- coding:utf-8 -*- #不带参数的get import requests import json host = "http://httpbin.org/" endpoint = "get" url = ''.join([host,endpoint]) r =

National characters in URI

妖精的绣舞 提交于 2020-01-24 16:17:35
问题 How should authors publish (by URI) resources with names containing non-ASCII (for example national) characters? Considering all the various parties (HTML code, browser sending request, browser saving file do disk, server receiving and processing request and server storing the file) all (possibly) using various encodings it seems nearly impossible to have it working consistently. Or at least I never managed. When it comes to web pages I’m already used to that and always replace national

National characters in URI

戏子无情 提交于 2020-01-24 16:15:21
问题 How should authors publish (by URI) resources with names containing non-ASCII (for example national) characters? Considering all the various parties (HTML code, browser sending request, browser saving file do disk, server receiving and processing request and server storing the file) all (possibly) using various encodings it seems nearly impossible to have it working consistently. Or at least I never managed. When it comes to web pages I’m already used to that and always replace national

学习jsonp

↘锁芯ラ 提交于 2020-01-24 16:02:16
jsonp 以前学过,当时就挺懵的,还全忘了,这次就当复习了一遍jsonp,😭 这里是解决客户端的跨域问题,服务端去解决跨域问题比这个简单只要加一个请求头就可以了 const express = require('express') const app = express() app.get('/', (req, res, next) => { console.log(`收到客户端请求了:${req.url}`) var data = JSON.stringify({ foo: 'bar', list: [1, 2, 3] }) setTimeout(function () { res.end(`${req.query.callback}(${data})`) }, 1000) }) app.listen(3000, () => { console.log('running...') }) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jsonp - 示例</title> </head> <body> <script> // 异步请求跨域限制(ajax) // 不同域名、不同协议、不同端口号 jsonp({ url: 'http://127.0.0.1:3000/', data: '',

How to purge / flush cache of NSString

别等时光非礼了梦想. 提交于 2020-01-24 15:21:05
问题 Currently I am doing simple tests of my app (written in xCode for MAC OS X) and I noticed that there are some issues when it comes to getting data from internet. So I am requesting some text data: NSString *dataFromInternet = [[NSString alloc] initWithContentsOfURL:url usedEncoding:&encoding error:&error]; Now: If internet works then everything is awesome. If internet disconnected then I am getting error in "error" however "dataFromInternet" still returns the very same data as if there was

Java-----Class.forName()在代码上无法执行报错NotFound解决方法

女生的网名这么多〃 提交于 2020-01-24 14:14:40
Java–Class.forName() 异常信息:ClassNotFoundException 前因: 在写JDBCUtils工具类的时候,发现测试时无法获取到正常的数据,查看日志后发现报错ClassNotFoundException。 错误原因: jar包导入正常 所有配置文件的配置信息正常 SQL语句以及其他代码编写正常 文件夹命名异常 在web目录下的创建的目录名称必须创建为WEB-INF,但是我创建的是WEB-INFO,随后创建的lib目录,放进了jar包,因此出现了该错误。 然而在最初的学习中也是创建的WEB-INFO目录,却可以运行正常,目前原因未知。 代码实现 配置文件 driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/userlogin username=root password=guoyuhang initialSize=5 maxActive=10 maxWait=3000 JDBC代码实现 package cn.itcast.util; import java.io.FileReader; import java.io.IOException; import java.net.URL; import java.sql.*; import java.util

猫眼电影影评爬取

别说谁变了你拦得住时间么 提交于 2020-01-24 13:07:21
文章目录 前言 思路分析 完整代码 总结 前言 前段时间,热播的电影《少年的你》,不知道大家看了吗?反正,我是看完了,至于这部电影怎么样,我就不做评论了,这个任务还是留给网友去做吧!好了,进入正题,今天我们要做的是猫眼电影影评的爬取。 下面我以电影《少年的你》为例进行分析。 思路分析 电影的影评接口如下(这个可以在网上搜到,也可以自己抓包分析): http://m.maoyan.com/mmdb/comments/movie/1218029.json? v =yes&offset=0 这里简单的分析一下参数的含义: 1218029:猫眼电影的ID(这里就是《少年的你》的电影ID了) offset:偏移,貌似是依次增加15 我们可以每次增加offset来进行爬取,即让offset每次增加15。我们通过这种方式来构造URL,发送请求即可。 关于数据存取,我们可以存储到数据库,也可保存到文件,这里由于我爬取的数据较少,就直接保存到文件了。 通过这个URL请求返回的是json数据,我们可以用Python的json模块进行解析,再用pandas保存成CSV文件就行了。 完整代码 # !/usr/bin/env python # —*— coding: utf-8 —*— # @Time: 2020/1/22 16:47 # @Author: Martin # @File: maoyan.py