我在當天想出了一些代碼,允許我將PDF文件下載到我的桌面上。它是用C#編寫的。將內容導入excel表
我有點嘗試做同樣的事情,但在PHP中。我想知道是否有人有我想要做的樣品。
我不確定是否可以在MS Word中完成。我用Excel做了類似的事情。
我正在嘗試使用Excel文件並從多個網站中抓取內容。
網站每半小時左右同時生成一個新查詢。
我希望能夠檢索內容並將內容導入到excel文件中,以便我可以嘗試重新排列信息。閱讀3到4個網站上的內容,並將其下載到excel文件中,以便用表格組織內容。
using System;
using System.IO;
using System.Net;
static class Program
{
static void Main()
{
string url = "http://www.uakron.edu/dotAsset/1265971.pdf", localPath = "1265971.pdf";
var req = (HttpWebRequest)WebRequest.Create(url);
req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
req.Headers.Add("Accept-Encoding","gzip,deflate");
if(File.Exists(localPath))
req.IfModifiedSince = File.GetLastWriteTimeUtc(localPath);
try
{
using (var resp = req.GetResponse())
{
int len;
checked
{
len = (int)resp.ContentLength;
}
using (var file = File.Create(localPath))
using (var data = resp.GetResponseStream())
{
byte[] buffer = new byte[4 * 1024];
int bytesRead;
while (len > 0 && (bytesRead = data.Read(buffer, 0, Math.Min(len, buffer.Length))) > 0)
{
len -= bytesRead;
file.Write(buffer, 0, bytesRead);
}
}
}
Console.WriteLine("New version downloaded");
}
catch (WebException ex)
{
if (ex.Response == null || ex.Status != WebExceptionStatus.ProtocolError)
throw;
Console.WriteLine("Not updated");
}
}
}
我試圖開發具有一定時間間隔的應用程序,所以它可以讓我確定我多少分鐘可以產生新的查詢是到文件中。我試圖用內聯樣式格式在php中生成代碼。所有的腳本。而不是C#,它需要多個文件。
這是我創建的一個工作網站。 (我不是試圖竊取內容。)
謝謝