我正在运行一个基于激励的推荐网站,其中一个要求是用户推特他们的推荐链接.在用户状态页面的"步骤"中,一旦他们的链接被推文,我希望"推文链接"的行要么消失,要么有一个删除,以显示它已经完成.
那么 - 有没有办法检查链接是否已被推文,并解析该行的不同文本/样式?
每个推荐链接都是唯一的,因此只能由该人发推文.
我正在处理使用 python 从推文文本中提取提及的代码。
参数是推文文本。这个函数应该返回一个包含推文中所有提及的列表,按照它们在推文中出现的顺序。返回列表中的每个提及都应删除初始提及符号,并且该列表应包含遇到的每个提及——包括重复,如果用户在推文中被多次提及。以下是两个示例:
>>>extract_mentions('@AndreaTantaros- You are a true journalistic\
professional. I so agree with what you say. Keep up the great\
work!@RepJohnLewis ')
['AndreaTantaros','RepJohnLewis']
>>>extract_mentions('@CPAC For all the closet #libertarians attending \
#CPAC2016 , I'll be there Thurs/Fri -- speaking Thurs. a.m. on the main\
stage. Look me up! @CPAC')
['CPAC','CPAC']
Run Code Online (Sandbox Code Playgroud)
提及以“@”符号开头,包含所有字母数字字符,直到(但不包括)空格字符、标点符号或推文结尾。
如何从字符串中提取提及?抱歉,我还没有了解正则表达式,还有其他方法吗?
我们需要一些电影的历史推文。现在,我们尝试了 twitter 的流 API 和搜索 API。流 API 不能给我们一个参数来选择我们需要的时间范围,搜索 API 只能提前一两周给我们数据。有没有办法提取2014-05-01到2014-07-01的历史推文(例如)?我发现以下方法可以做到这一点:
1:推特高级搜索 https://twitter.com/search-advanced?lang=en 可以找到我需要的搜索结果。但是我怎么能下载搜索结果呢?反正有没有写代码并保存搜索结果?
2:像topsy一样使用推特分析网站。但它也有保存结果的困难。
3:似乎像 twitter4J 这样的一些包可以帮助解决这个问题:http : //twitter4j.org/en/code-examples.html 有没有任何 python 或 R 包可以帮助我们做到这一点?
4:我们需要这些数据来做研究。花费很长时间来提取数据并不是一个好的选择。反正有没有从一些专业网站购买这些数据?
我试图在雅虎卷发服务上测试php_curl,但是我从雅虎收到了一个错误.
// create a new cURL resource
$handle = curl_init();
// set URL and other appropriate options
// http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=persimmon&results=10
curl_setopt_array(
$handle,
array(
CURLOPT_URL => 'http://search.yahooapis.com/WebSearchService/V1/webSearch',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => 'appid=YahooDemo&query=test&results=10',
CURLOPT_RETURNTRANSFER => true
)
);
$response = curl_exec($handle);
curl_close($handle);
$xml = new SimpleXMLElement($response);
foreach($xml->Result as $x) {
echo $x->Title.'<br/>';
}
echo '<pre>';
print_r($xml);
Run Code Online (Sandbox Code Playgroud)
结果:
SimpleXMLElement Object
(
[Message] => The service has been shut down. For further details, please see the Deprecated Services blog post http://developer.yahoo.com/blogs/ydn/posts/2010/08/api_updates_and_changes
)
Run Code Online (Sandbox Code Playgroud)
自从该服务被弃用以来从yahoo …
我正在整合Twitter与Android它显示流动的错误请帮助解决错误
{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}
对于给定的用户,我想计算他在给定时间内为所有推文获得的转发总数,以便开始更新.
例如,如果用户John在2015-01-01至2015-01-30期间推出了100条推文,并且如果这100条推文中的30条到目前为止总共有60条推文,那么我想提取该值60.
我在这里看到@Ben的相关答案.
代码片段很有用.
谢谢.