我可以编程方式下载电子纸吗? [英] Can I download E-Paper programatically?
问题描述
我要求从新闻纸网站下载电子报纸,例如。
我们将有一个报纸链接
< a href =http://epaperbeta.timesofindia.com/index.aspx?eid=31808&dt=20150905> http://epaperbeta.timesofindia.com/index.aspx?eid=31808&dt=20150905 [ ^ ] *只是一个测试的演示链接。
我们需要通过代码下载这份新闻纸PDF并将其保存在某个文件夹中。将有几个电子报的网站表格我们将下载新闻纸PDF。
谢谢..
I have a requirement to download epaper from the news paper sites for eg.
we will have a link of newspaper
http://epaperbeta.timesofindia.com/index.aspx?eid=31808&dt=20150905[^] * its just a demo link to test.
we need to download this news paper PDFs through code and save the same in some folder. There will be several e-papers site form which we will download news paper PDFs.
Thanks..
推荐答案
HI。
这个过程有点棘手,你需要建立一个专门的html解析逻辑,具体取决于你所针对的新闻纸网站。
假设你的目标是
http://epaperbeta.timesofindia.com/index.aspx?eid=31808&dt=20150905 [ ^ ]
然后弄明白你如何在这里获得PDF的网址html页面。
只是为了线索我可以告诉你顶部的下载链接可以调用下面的java脚本代码。
< br $> b $ b
HI.
Its a bit tricky process and you need to build a specialized html parsing logic depending on which news paper site you are targeting.
Suppose you are targeting
http://epaperbeta.timesofindia.com/index.aspx?eid=31808&dt=20150905[^]
Then figure out how you get url of PDF inside this html page.
Just for clue I can tell you that download link available at the top which invokes the below java script code.
function downloadpdftest() {
var getslidevalue = parseInt(sudoSlider.getValue("currentSlide"), 10);
var nextsudoslider = sudoSlider.getSlide(getslidevalue);
var nextslideid = nextsudoslider.find('img').attr('src');
var fPath = nextslideid.toString();
fPath = fPath.replace(".JPG", ".pdf");
fPath = fPath.replace(".jpg", ".pdf");
var currPDFName = fPath.replace("Page", "PagePrint");
window.open(currPDFName, 'PDF', 'left=150,top=10,width=750,height=700,scrollbars=yes,status=yes');
}
现在尝试使用WebRequest或WebClient通过在c#中获取此页面的内容来生成currPDFName(pdf url)等级。
http://stackoverflow.com/questions/16642196/get-html-code-from-a-website-c-sharp [ ^ ]代码见
然后解析html以生成PDF网址。
一旦获得pdf网址,然后在下面用于下载PDF文件的代码。
Now try to generate currPDFName (pdf url) by fetching the content of this page in c# using WebRequest or WebClient Class.
http://stackoverflow.com/questions/16642196/get-html-code-from-a-website-c-sharp[^]code see
Then parse html to generate PDF url.
Once you get pdf url then below code to download PDF file.
using(WebClient client = new WebClient())
{
client.DownloadFile("http://www.irs.gov/pub/irs-pdf/fw4.pdf", @"C:\Temp.pdf");
}
http://stackoverflow.com/questions/2913830/download-pdf-programatically [ ^ ]
这篇关于我可以编程方式下载电子纸吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!