GVKun编程网logo

Android:如何在网站包含时下载RSS:link rel =“alternate”type =“application / rss xml”

15

在本文中,您将会了解到关于Android:如何在网站包含时下载RSS:linkrel=“alternate”type=“application/rssxml”的新资讯,并给出一些关于$.ajax中co

在本文中,您将会了解到关于Android:如何在网站包含时下载RSS:link rel =“alternate”type =“application / rss xml”的新资讯,并给出一些关于$.ajax中contentType: “application/json” 的用法、$.ajax中contentType: “application/json” 的用法详解、.net – 消耗webservice的错误,内容类型“application/xop xml”与预期类型不匹配“text/xml”、2 pieces of AFE papers——initiation,Alternative Promoters(both for the first exon splice)的实用技巧。

本文目录一览:

Android:如何在网站包含时下载RSS:link rel =“alternate”type =“application / rss xml”

我正在制作一个RSS相关的应用程序.
我希望能够下载仅包含以下网站URL的RSS(xml):

link rel =“alternate”type =“application / RSS xml”

例如,http://www.engaget.com源包含:

<link rel="alternate" type="application/RSS+xml" title="Engadget" href="http://www.engadget.com/RSS.xml">

我假设如果我将此站点作为RSS应用程序打开,它将重定向到http://www.engadget.com/rss.xml页面.

我下载xml的代码如下:

private boolean downloadXml(String url,String filename) {
        try {
            URL   urlxml = new URL(url);
            URLConnection ucon = urlxml.openConnection();
            ucon.setConnectTimeout(4000);
            ucon.setReadTimeout(4000);
            InputStream is = ucon.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is,128);
            FileOutputStream fOut = openFileOutput(filename + ".xml",Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE);
            OutputStreamWriter osw = new OutputStreamWriter(fOut);
            int current = 0;
            while ((current = bis.read()) != -1) {
                osw.write((byte) current);
            }
            osw.flush();
            osw.close();

        } catch (Exception e) {
            return false;
        }
        return true;
    }

在我不知道’http://www.engadget.com/RSS.xml’url的情况下,当我输入’http://www.engadget.com’时如何下载RSS?

解决方法

要实现这一目标,您需要:

>检测URL是否指向HTML文件.请参阅下面的代码中的isHtml方法.
>如果URL指向HTML文件,请从中提取RSS URL.请参阅下面的代码中的extractRSSUrl方法.

以下代码是您在问题中粘贴的代码的修改版本.对于I / O,我使用Apache Commons IO作为有用的IoUtils和FileUtils类. IoUtils.toString用于将输入流转换为字符串,如文章“In Java,how do I read/convert an InputStream to a String?”中所建议的那样

extractRSSUrl使用正则表达式来解析HTML,即使它非常不受欢迎. (参见“RegEx match open tags except XHTML self-contained tags”中的咆哮.)考虑到这一点,让extractRSSUrl成为一个起点. extractRSSUrl中的正则表达式是基本的,并未涵盖所有情况.

请注意,对isRSS(str)的调用已被注释掉.如果要进行RSS检测,请参阅“How to detect if a page is an RSS or ATOM feed”.

private boolean downloadXml(String url,String filename) {
    InputStream is = null;
    try {
        URL urlxml = new URL(url);
        URLConnection ucon = urlxml.openConnection();
        ucon.setConnectTimeout(4000);
        ucon.setReadTimeout(4000);
        is = ucon.getInputStream();
        String str = IoUtils.toString(is,"UTF-8");
        if (isHtml(str)) {
            String RSSURL = extractRSSUrl(str);
            if (RSSURL != null && !url.equals(RSSURL)) {
                return downloadXml(RSSURL,filename + ".xml");
            }
        } else { // if (isRSS(str)) {
            // For Now,we''ll assume that we''re an RSS Feed at this point
            FileUtils.write(new File(filename),str);
            return true;
        }
    } catch (Exception e) {
        // do nothing
    } finally {
        IoUtils.closeQuietly(is);
    }
    return false;
}

private boolean isHtml(String str) {
    Pattern pattern = Pattern.compile("<html",Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
    Matcher matcher = pattern.matcher(str);
    return matcher.find();
}

private String extractRSSUrl(String str) {
    Pattern pattern = Pattern.compile("<link(?:\\s+href=\"([^\"]*)\"|\\s+[a-z\\-]+=\"[^\"]*\")*\\s+type=\"application/RSS\\+(?:xml|atom)\"(?:\\s+href=\"([^\"]*)\"|\\s+[a-z\\-]+=\"[^\"]*\")*?\\s*/?>",Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
    Matcher matcher = pattern.matcher(str);
    if (matcher.find()) {
        for (int i = 1; i <= matcher.groupCount(); i++) {
            if (matcher.group(i) != null) {
                return matcher.group(i);
            }
        }
    }
    return null;
}

上面的代码适用于您的Engadget示例:

obj.downloadXml("http://www.engadget.com/","RSS");

$.ajax中contentType: “application/json” 的用法

$.ajax中contentType: “application/json” 的用法

https://blog.csdn.net/calyxmelo/article/details/54969244

不使用contentType: “application/json”则data可以是对象

$.ajax({
url: actionurl,type: "POST",datType: "JSON",data: { id: nodeId },async: false,success: function () {}
});
1
2
3
4
5
6
7
8
使用contentType: “application/json”则data只能是json字符串

$.ajax({
url: actionurl,contentType: "application/json"
data: "{‘id‘: " + nodeId +"}",success: function () {}
});


//请求后端接口,获取数据function getRequestData(method,url,reqData,callBack){ $.ajax({ type : method,url : url,data : JSON.stringify(reqData),contentType:"application/json",dataType:‘json‘,success : function(result) { callBack(result); } });}

$.ajax中contentType: “application/json” 的用法详解

$.ajax中contentType: “application/json” 的用法详解

具体内容如下所示:

$.ajax({
  type: httpMethod,
  cache:false,
  async:false,
  contentType: "application/json; charset=utf-8",
  dataType: "json",//返回值类型
  url: path+url,
  data:jsonData,
  success: function(data){
    var resultData = ''返回码=''+data.status+'',响应结果=''+data.message+'',耗时=''+data.tcost;
    layer.msg(resultData,{icon: 1});
  },
  error : function(xhr, ts, et) {
    layer.msg(''服务调用失败!'', {icon: 2});
  }
});

区分:

contentType: 发送信息至服务器时内容编码类型,简单说告诉服务器请求类型的数据

 默认值: "application/x-www-form-urlencoded"

dataType:告诉服务器,我要想什么类型的数据,除了常见的json、XML,还可以指定 html、jsonp、script或者text

不使用contentType: “application/json”则data可以是对象

$.ajax({
url: actionurl,
type: "POST",
datType: "JSON",
data: { id: nodeId },
async: false,
success: function () {}
});

使用contentType: “application/json”则data只能是json字符串

$.ajax({
url: actionurl,
type: "POST",
datType: "JSON",
contentType: "application/json"
data: "{''id'': " + nodeId +"}",
async: false,
success: function () {}
});

总结

以上所述是小编给大家介绍的$.ajax中contentType: “application/json” 的用法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

您可能感兴趣的文章:
  • 跨域解决之JSONP和CORS的详细介绍
  • JSON生成Form表单的方法示例
  • 简单说说angular.json文件的使用
  • JavaScript根据json生成html表格的示例代码
  • MongoDB使用mongoexport和mongoimport命令,批量导出和导入JSON数据到同一张表的实例
  • nodejs读取本地中文json文件出现乱码解决方法
  • Go语言的JSON处理详解
  • JavaScript JSON使用原理及注意事项

.net – 消耗webservice的错误,内容类型“application/xop xml”与预期类型不匹配“text/xml”

.net – 消耗webservice的错误,内容类型“application/xop xml”与预期类型不匹配“text/xml”

在为我公司购买的产品消费webservice时,我有一个奇怪的问题。该产品称为“运动指挥官”,由“Vision Vision”公司制造。我们正在尝试使用“数据批量更新SOAP API”。

每当我尝试调用webservice上的任何方法时,调用实际上会成功,但是当处理响应时客户端失败,并且我收到异常。

错误的细节如下,谢谢你们可以提供的任何帮助。

使用Web引用错误(旧式webservice客户端)

当作为Web引用使用该服务时,我得到一个InvalidOperationException用于我所做的任何调用,并显示以下消息:

Client found response content type of ''multipart/related; type="application/xop+xml"; boundary="uuid:170e63fa-183c-4b18-9364-c62ca545a6e0"; start="<root.message@cxf.apache.org>"; start-info="text/xml"'',but expected ''text/xml''.
The request Failed with the error message:
--

--uuid:170e63fa-183c-4b18-9364-c62ca545a6e0
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-transfer-encoding: binary
Content-ID: <root.message@cxf.apache.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ns2:openApiConnectionResponse xmlns:ns2="http://api.service.apibatchmember.emailvision.com/" xmlns:ns3="http://exceptions.service.apibatchmember.emailvision.com/">
      <return>DpKTe-9swUeOsxhHH9t-uLPeLyg-aa2xk3-aKe9oJ5S9Yymrnuf1FxYnzpaFojsQSkSCbJsZmrZ_d3v2-7Hj</return>
    </ns2:openApiConnectionResponse>
  </soap:Body>
</soap:Envelope>
--uuid:170e63fa-183c-4b18-9364-c62ca545a6e0--
--.

如你所见,响应肥皂包看起来是有效的(这是一个有效的响应,并且调用成功),但客户端似乎对内容类型有问题并产生异常。

使用服务引用错误(WCF客户端)

当我将服务作为服务参考使用时,我会收到一个ProtocolException用于我所做的任何调用,并显示以下消息:

The content type multipart/related; type="application/xop+xml"; boundary="uuid:af66440a-012e-4444-8814-895c843de5ec"; start="<root.message@cxf.apache.org>"; start-info="text/xml" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder,be sure that the IsContentTypeSupported method is implemented properly. The first 648 bytes of the response were: ''
--uuid:af66440a-012e-4444-8814-895c843de5ec
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-transfer-encoding: binary
Content-ID: <root.message@cxf.apache.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ns2:openApiConnectionResponse xmlns:ns2="http://api.service.apibatchmember.emailvision.com/" xmlns:ns3="http://exceptions.service.apibatchmember.emailvision.com/">
      <return>Dqaqb-MJ9V_eplZ8fPh4tdHUbxM-ZtuZsDG6galAGZSfSzyxgtuuIxZc3aSsnhI4b0SCbJsZmrZ_d3v2-7G8</return>
    </ns2:openApiConnectionResponse>
  </soap:Body>
</soap:Envelope>
--uuid:af66440a-012e-4444-8814-895c843de5ec--''.

就像前面的例子一样;我们有一个有效的soap响应,并且调用成功,但客户端似乎对内容类型有问题,并产生了异常。

有没有我可以设置的选项,所以客户端没有响应类型的问题?我已经做了一些谷歌的搜索,但我发现没有什么帮助我到目前为止。

解决方法

对于同样问题的人来说,我已经找到一个消费Web服务作为服务引用(WCF)的解决方案。 BasicHttpBinding.MessageEncoding属性需要设置为“Mtom”。

以下是所需配置设置的代码段:

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding messageEncoding="Mtom">          
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

编辑:如果您有与自定义绑定相同的问题,请参阅answer from @robmzd。

我仍然没有找到一个解决方案来消费它作为一个旧式的Web引用。

2 pieces of AFE papers——initiation,Alternative Promoters(both for the first exon splice)

2 pieces of AFE papers——initiation,Alternative Promoters(both for the first exon splice)

---恢复内容开始---

《A paired-end sequencing strategy to map the complex landscape of transcription initiation》

《Tissue-Specific and Ubiquitous Expression Patterns from Alternative Promoters of Human Genes》

第一篇:来自nature method

用的是果蝇的胚胎RNASeq数据分析了其TSS部位的initiation landscape,也就是本人所感兴趣的AFE,在哺乳动物体内也发现了可以用特定motif表征的相似的启动子部位特征。再有,他们发现了5‘帽子端的转录起源于编码的外显子,从本文章中看来,他们的发现TSS的存在并不是形成转录本的过程中选择性剪切的结果,而是转录前的基因coding region的改造作用所产生的产物,证明了paired-end tss analysis to be a powerful method to uncover the transcriptional complexity of eukaryotic genomes.

其中想说的是作者的开篇:

recent studies using high-throughput sequencing protocols have uncovered the complexity of mammalian transcription by rnA polymerase ii,helping to de ne several initiation patterns in which transcription start sites (tsss) cluster in both narrow and broad genomic windows. 

分享图片

遣词造句还不错

key words:

TSS:Central to this process is the core promoter region of ~100 nucleotides (nt) surrounding the transcription start site (TSS) of a gene

TSS区域的作用是其间DNA motif sequence 保证了RNA转录酶的召集,从而启动转录, 

CAGE:the capped analysis of gene expres-sion (CAGE) protocol has been used to generate comprehensive

mammalian libraries of short sequence tags,(CAGE的一般作用)which have led to the identification of distinct transcription initiation patterns

TATA Box:an over- representation of the canonical TATA Box sequence motif in ‘single-peak’ promoters and CpG islands overlapping ‘broad range’ promoters

目前5‘端的seqing technology有CAGE protocol,deep CAGE protocol,PEAT(本篇作者团队开发的,杜克大学药学院)

PEAT:paired--end analysis of TSSs

分享图片

PEAT的strategy图示:RCA:rolling circle amplification(特色)

########################## 

3′ reads were mostly mapped to coding regions of annotated genes,indicating the success of the paired-end library construction.

mapping之后的reads类型分布,类型不仅仅显示了3’、5’的测序结果异同,多少也显示了测序深度的大小。3’端数据大多映射到了编码区域也反映了双端建库的成功。

分享图片

Characterization of read clusters and initiation patterns:TSS clusters and initiation patterns identified in the Drosophila embryo.

a图揭示了5‘端的TSS Tags 组成的density estimate plot,并且TSS 包含95% of the reads的cluster被密集的表示在黑线以及棕黄色area。

b图是所有大于100bpreads的cluster的基因位置饼图,分类的依据则是相应转录组的注释位置以及所给cluster分配的模式。

c图很直观,d图:TSS的窄峰、宽峰、弱峰的分布情况

分享图片

Promoter motifs associated with distinct promoter types:Initiation patterns are linked to specific core promoter

In mammals,‘single-peak’ and ‘broad-range’ promoters tend to be associated with TATA Box sequence and CpG islands As the fly genome does not contain CpG islands,our identification of BP and WP promoters was intriguing

#######

Unlike mammalian WP promoters,which have been associated with CpG islands,Drosophila WP promoters were strongly associated with three motifs (motif 1,DRE and motif 7):果蝇种属中的weak promoter不似哺乳动物中的weak peak与CpG islands呈很高的相关性,而是与三种motifs有很高的相关性。

BP promoters,which have characteristics of both NP and WP promoters,showed a combination of the most frequent motifs found in the other promoter types。而对于broad peak的 promoter的motifs则是结合NP以及WP的motifs的结合体,拥有两种promoters的motifs的co-features

其中:

The Inr motif and motif 1 had in common a strongly conserved ‘TCA’ trinucleotide (the minimal initiator consensus sequence,而TCA又是最小启动子一致序列).

Likewise,motif 6 was enriched at the same location as the TATA Box and contains a minimal TAT consensus sequence that is also present in the canonical TATA motif, suggesting that motif 6 and motif 1 combination is an alternative to the classic TATA Box and Inr motif pair

---恢复内容开始---

《A paired-end sequencing strategy to map the complex landscape of transcription initiation》

《Tissue-Specific and Ubiquitous Expression Patterns from Alternative Promoters of Human Genes》

第一篇:来自nature method

用的是果蝇的胚胎RNASeq数据分析了其TSS部位的initiation landscape,也就是本人所感兴趣的AFE,在哺乳动物体内也发现了可以用特定motif表征的相似的启动子部位特征。再有,他们发现了5‘帽子端的转录起源于编码的外显子,从本文章中看来,他们的发现TSS的存在并不是形成转录本的过程中选择性剪切的结果,而是转录前的基因coding region的改造作用所产生的产物,证明了paired-end tss analysis to be a powerful method to uncover the transcriptional complexity of eukaryotic genomes.

其中想说的是作者的开篇:

recent studies using high-throughput sequencing protocols have uncovered the complexity of mammalian transcription by rnA polymerase ii, suggesting that motif 6 and motif 1 combination is an alternative to the classic TATA Box and Inr motif pair 

今天关于Android:如何在网站包含时下载RSS:link rel =“alternate”type =“application / rss xml”的讲解已经结束,谢谢您的阅读,如果想了解更多关于$.ajax中contentType: “application/json” 的用法、$.ajax中contentType: “application/json” 的用法详解、.net – 消耗webservice的错误,内容类型“application/xop xml”与预期类型不匹配“text/xml”、2 pieces of AFE papers——initiation,Alternative Promoters(both for the first exon splice)的相关知识,请在本站搜索。

本文标签: