首页 \ 问答 \ cURL选项 - 会话和cookie(cURL Option - session and cookie)

cURL选项 - 会话和cookie(cURL Option - session and cookie)

在脚本中,我使用cURL登录或将一些信息发布到另一个站点。

当用户加载此脚本时,我们没有任何问题,但是当两个用户同时加载脚本时,另一个站点加载第一页,因为我们的主机中的cookie为一个用户设置,并且该站点从用户获得两个不同的命令。

如果为该站点为每个用户获取不同的SESSION和COOKIE的任何用户加载脚本,我该怎么做?

$ch = curl_init();
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
$result = curl_exec($ch);
return $result;  

In a script I used cURL for login or post some information to another site.

When a user loads this script we have not any problem but when two user simultaneously load script the another site loads first page, because the cookie in our host set for one user, and the site get two different commands from a user.

How can I do that when the script was loaded for any user that the site get different SESSION and COOKIE to each user?

$ch = curl_init();
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
$result = curl_exec($ch);
return $result;  

原文:https://stackoverflow.com/questions/30583079
更新时间:2023-06-18 15:06

最满意答案

根据你的问题,你想比较两个句子,然后可能找出他们匹配的百分比。

要查找句子之间的相似性,您可以使用Jaccard SimilarityCosine Similarity

请参阅此余弦相似度如何计算2个句子字符串的余弦相似度? - Python

如果余弦相似度小于那么句子也不相似,但如果它更接近1那么句子是相似的

NLTK可用于查找句子中单词的同义词,以便您可以从句子中获取语义。

要查找同义词,您可以使用以下代码:

from nltk.corpus import wordnet as wn
wn.synsets(your word)

According to your question you want to compare two sentences and then probably find out how much percentage they match.

For finding the similarity between sentences you can use Jaccard Similarity or Cosine Similarity.

Refer this for Cosine Similarity How to calculate cosine similarity given 2 sentence strings? - Python

If the cosine similarity is less then the sentences are nor similar but if it is closer to 1 then the sentences are similar

NLTK can be used to find the synonyms of the words in the sentence so that you can get semantics from the sentence.

For finding synonyms you could use the following code:

from nltk.corpus import wordnet as wn
wn.synsets(your word)

相关问答

更多
  • 这将是答案。 即时可用的PHP功能。 This would be the answer. Ready-to-use PHP function.
  • 莱文斯坦距离就是这样的一个衡量标准。 它基本上告诉你需要编辑,删除或添加多少个字符,才能从第一个字符串到第二个字符串。 我不确定某些数据库系统是否支持该功能。 但是我确实知道一些名为Soundex的简化算法在某些数据库系统中得到了支持。 The Levenstein distance is such a measure. It basically tells you how many characters need to be edited, deleted or added, to get from th ...
  • 您正在寻找重叠的正则表达式匹配。 简单地说,使用python中的默认正则表达式引擎并不容易。 但是,您可以使用regex模块(先将pip install )。 调用regex.findall并设置overlapped=True 。 import regex a, b = ' ', '(' text = 'here is an example()' regex.findall('{}(.*?){}'.format(*map(re.escape, (a, b))), text, overlapped=Tr ...
  • 根据你的问题,你想比较两个句子,然后可能找出他们匹配的百分比。 要查找句子之间的相似性,您可以使用Jaccard Similarity或Cosine Similarity 。 请参阅此余弦相似度如何计算2个句子字符串的余弦相似度? - Python 如果余弦相似度小于那么句子也不相似,但如果它更接近1那么句子是相似的 NLTK可用于查找句子中单词的同义词,以便您可以从句子中获取语义。 要查找同义词,您可以使用以下代码: from nltk.corpus import wordnet as wn wn.syn ...
  • Currency默认构造函数是: Currency() : _next(NULL), _prev(NULL), _position(0) {} 并且似乎没有为_coin分配任何内存。 您的Exchange::Exchange(std::string str)构造函数也执行: _currencies = new Currency; 它调用Currency的默认构造函数,然后传递给parseTradePairs() ,所以很可能是这一行: curr->_coin->setExch(temp); 因此,我试 ...
  • 首先,NLTK的word_tokenize()可能不适合您输入的希腊数据; 默认的nltk.tokenize.word_tokenize()在英语Penn nltk.tokenize.word_tokenize()上进行培训,请参阅https://nltk.googlecode.com/svn/trunk/doc/api/nltk.tokenize.treebank.TreebankWordTokenizer-class.html 我不确定你是否得到了正确的标记化,但由于希腊语使用空格作为标记分隔符,NLT ...
  • 您需要单独传递单词而不是在加入单词后传递单词。 from nltk.corpus import wordnet as wn def getSynonyms(word1): synonymList1 = [] for data1 in word1: wordnetSynset1 = wn.synsets(data1) tempList1=[] for synset1 in wordnetSy ...
  • 你需要一本字典来将NLTK POS标签翻译成WordNet标签: pos_translate = {'J':'a', 'V':'v', 'N':'n', 'R':'r'} 现在,提取POS标签,翻译每个标签,如果可能的话(如果可能的话,选择一个默认标签,比如说, "n" ,并且引理: text = ['This', 'is', 'a', 'car', '.'] [lemmatizer.lemmatize(w,\ pos=pos_translate[pos[0]] if pos[0] in p ...
  • 从解释器中输入 import nltk import sys print(nltk) print(sys.executable) 然后创建一个具有相同内容的脚本并运行 python script.py 请发布输出。 From the interpreter, type import nltk import sys print(nltk) print(sys.executable) and then create a script with the same contents and run pytho ...
  • 在EdChums上建立评论这里是一种从CountVectorizer获得(我假设全局)字数的方法: import pandas as pd from sklearn.feature_extraction.text import CountVectorizer vect= CountVectorizer() df= pd.DataFrame({'text':['cat on the cat','angel eyes has','blue red angel','one two blue','blue wha ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。