urlencode

短信验证

匿名 (未验证) 提交于 2019-12-02 23:57:01
package cn;import net.sf.json.JSONObject;import java.io.*;import java.net.HttpURLConnection;import java.net.URL;import java.net.URLEncoder;import java.util.HashMap;import java.util.Map;/** *短信API服务调用示例代码 - 聚合数据 *在线接口文档:http://www.juhe.cn/docs/54 **/public class JuheDemo { public static final String DEF_CHATSET = "UTF-8"; public static final int DEF_CONN_TIMEOUT = 30000; public static final int DEF_READ_TIMEOUT = 30000; public static String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36"; //配置您申请的KEY public static final String

Django自定义分页并保存搜索条件

匿名 (未验证) 提交于 2019-12-02 23:55:01
Django自定义分页并保存搜索条件 1、自定义分页组件pagination.py import copy class Pagination: def __init__(self, current_page_num, all_count, request, per_page_num=10, page_count=11): """ 封装分页相关数据 :param current_page_num: 当前页码数 :param all_count: 数据库中总数据条数 :param per_page_num: 每页显示的数据量 :param page_count: 最大显示页数 """ try: current_page = int(current_page_num) except Exception as e: current_page = 1 # 页码数小于1时显示第一页 if current_page < 1: current_page = 1 # 取总页码数 self.all_page_count, temp = divmod(all_count, per_page_num) if temp: self.all_page_count += 1 # 页码数大于最大页码数时显示最后一页 if current_page > self.all_page_count: current

(C++)UrlEncode的标准实现

匿名 (未验证) 提交于 2019-12-02 23:03:14
关于UrlEncode的实现(C++),网上有很多不同的版本,对需要编码的字符集的选取并不统一。那么到底有没有标准呢?答案是有的,参见wiki 绝对不编码的,只有字母、数字、短横线(-)、下划线(_)、点(.)和波浪号(~),其他字符要视情况而定,所以一般性的urlencode只需保留上述字符不进行编码。 下面给出实现: unsigned char ToHex(unsigned char x) { return x > 9 ? x + 55 : x + 48; } unsigned char FromHex(unsigned char x) { unsigned char y; if (x >= 'A' && x <= 'Z') y = x - 'A' + 10; else if (x >= 'a' && x <= 'z') y = x - 'a' + 10; else if (x >= '0' && x <= '9') y = x - '0'; else assert(0); return y; } std::string UrlEncode(const std::string& str) { std::string strTemp = ""; size_t length = str.length(); for (size_t i = 0; i < length; i++) {

HttpUtility.UrlEncode in console application

这一生的挚爱 提交于 2019-12-02 21:57:25
I'd like to use HttpUtility.UrlEncode in a console application, VB.NET, VS 2010 Beta 2. System.Web.HttpUtility.UrlEncode(item) Error message: 'HttpUtility' is not a member of 'Web'. In this question Anjisan suggests to add a reference to System.Web, as follows: In your solution explorer, right click on references Choose "add reference" In the "Add Reference" dialog box, use the .NET tab Scroll down to System.Web, select that, and hit ok However, I don't have a System.Web entry at that location. Rubens Farias System.Web is there, but seems Visual Studio doesn't sort by name by default. You'll

Why is System.Web.HttpUtility.UrlEncode giving namespace name doesn't exist in Visual C# 2008?

你离开我真会死。 提交于 2019-12-02 20:30:38
I'm trying to encode a URL using the HttpUtility.UrlEncode() method, why am I getting The type or namespace name 'HttpUtility' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) error ? I'm using Visual C# 2008, Express Edition. The code I'm using is simplistic: using System; using System.Text; using System.Windows.Forms; using System.Net; using System.IO; using System.Web; namespace Lincr { public partial class frmMain : Form { public frmMain() { InitializeComponent(); } private void cmdShorten_Click(object sender, EventArgs e) { WebRequest wrURL; Stream

How to URL encode in Python 3?

流过昼夜 提交于 2019-12-02 20:08:22
I have tried to follow the documentation but was not able to use urlparse.parse.quote_plus() in Python 3 : from urllib.parse import urlparse params = urlparse.parse.quote_plus({'username': 'administrator', 'password': 'xyz'}) I get AttributeError: 'function' object has no attribute 'parse' You misread the documentation. You need to do two things: Quote each key and value from your dictionary, and Encode those into a URL Luckily urllib.parse.urlencode does both those things in a single step, and that's the function you should be using. from urllib.parse import urlencode, quote_plus payload = {

C# Escape Plus Sign (+) in POST using HttpWebRequest

别来无恙 提交于 2019-12-02 19:48:00
问题 I'm having issues to send POST data that includes characteres like "+" in the password field, string postData = String.Format("username={0}&password={1}", "anyname", "+13Gt2"); I'm using HttpWebRequest and a webbrowser to see the results, and when I try to log in from my C# WinForms using HttpWebRequest to POST data to the website, it tells me that password is incorrect. (in the source code[richTexbox1] and the webBrowser1). Trying it with another account of mine, that does not contain '+'

Ampersand causing returned text to be cut off in URL

断了今生、忘了曾经 提交于 2019-12-02 19:21:15
问题 I have inherited several php scripts from the person who maintaned the code before. He had no programming experience and mostly threw things together the best he could. today I had to rewrite a plug-in file for wordpress and now I can't figure out what is going wrong. The issue I am facing is that when diplaying the returned file names in the else statement that is part of the table ( <?php echo $result->display_name; ?> ) I get unexpected results. Let's say our database has a file called

PHP: convert spaces in string into %20?

只谈情不闲聊 提交于 2019-12-02 17:13:49
How can I convert spaces in string into %20 ? Here is my attempt: $str = "What happens here?"; echo urlencode($str); The output is "What+happens+here%3F" , so the spaces are not represented as %20 . What am I doing wrong? Use the rawurlencode function instead. The plus sign is the historic encoding for a space character in URL parameters, as documented in the help for the urlencode() function. That same page contains the answer you need - use rawurlencode() instead to get RFC 3986 compatible encoding. I believe that, if you need to use the %20 variant, you could perhaps use rawurlencode() . 来源

C# Escape Plus Sign (+) in POST using HttpWebRequest

人盡茶涼 提交于 2019-12-02 12:21:01
I'm having issues to send POST data that includes characteres like "+" in the password field, string postData = String.Format("username={0}&password={1}", "anyname", "+13Gt2"); I'm using HttpWebRequest and a webbrowser to see the results, and when I try to log in from my C# WinForms using HttpWebRequest to POST data to the website, it tells me that password is incorrect. (in the source code[richTexbox1] and the webBrowser1). Trying it with another account of mine, that does not contain '+' character, it lets me log in correctly (using array of bytes and writing it to the stream) byte[]