简体   繁体   English

在 web 应用程序上与 javascript 交互的桌面应用程序/脚本

[英]desktop application / script to interact with javascript on web application

My work has tasked me with determining the feasibility of migrating our existing in-house built change management services(web based) to a Sharepoint solution.我的工作要求我确定将我们现有的内部构建变更管理服务(基于 Web)迁移到 Sharepoint 解决方案的可行性。 I've found everything to be easy except I've run into the issue that for each change management issue (several thousand) there may be any number of attachment files associated with them, called through javascript, that need to be downloaded and put into a document library.我发现一切都很简单,除了我遇到的问题是,对于每个变更管理问题(数千个),可能有任意数量的附件文件与之关联,通过 javascript 调用,需要下载并放入一个文档库。

(ex. ... onClick="DownloadAttachment(XXXXX,'ProjectID=YYYY');return false">Attachment... ). (例如 ... onClick="DownloadAttachment(XXXXX,'ProjectID=YYYY');return false">附件...)。

To keep me from manually selecting them all I've been looking over posts of people wanting to do similar, and there seem to be many possible solutions, but they often seem more complicated than they need to be.为了不让我手动选择它们,我一直在查看想要做类似事情的人的帖子,似乎有很多可能的解决方案,但它们通常看起来比他们需要的更复杂。

So I suppose in a nutshell I'm asking what would be the best way to approach this issue that yields some sort of desktop application or script that can interact with web pages and will let me select and organize all the attachments.所以我想简而言之,我想问什么是解决这个问题的最佳方法,它产生某种桌面应用程序或脚本,可以与 web 页面交互,并让我 select 并组织所有附件。 (Making a purely web based app (php, javascript, rails, etc.) is not an option for me, so throwing that out there now). (制作一个纯粹的基于 web 的应用程序(php、javascript、rails 等)对我来说不是一个选择,所以现在把它扔在那里)。

Thanks in advance.提前致谢。

  1. Given a document id and project id, XXXXX and YYYY respectively in your example, figure out the URL from which the file contents can be downloaded.在您的示例中分别给定文档 ID 和项目 ID, XXXXXYYYY ,找出可以从中下载文件内容的 URL。 You can observe a few URL links in the browser and detect the pattern which your web application uses.您可以在浏览器中观察一些 URL 链接并检测您的 web 应用程序使用的模式。

  2. Use a tool like Selenium to get a list of XXXXX s and YYYY s of documents you need to download.使用 Selenium 之类的工具来获取您需要下载的文档的XXXXXYYYY的列表。

  3. Write a bash script with wget to download the files locally and put in the correct folders.使用 wget 编写 bash 脚本,将文件下载到本地并放入正确的文件夹中。

This is a "one off" migration, right?这是“一次性”迁移,对吗?

  1. Get access to your in-house application's database, and create an SQL query which pulls out rows showing the attachment names ( XXXXX ?) and the issue/project ( YYYY ?), ex:访问您的内部应用程序的数据库,并创建一个 SQL 查询,该查询拉出显示附件名称( XXXXX ?)和问题/项目( YYYY ?)的行,例如:

     |file_id|issue_id|file_name | | 5| 123|Feasibility Test.xls|
  2. Analyze the DownloadAttachment method and figure out how it generates the URL that it calls for each download.分析DownloadAttachment方法并弄清楚它如何生成它为每次下载调用的 URL。

  3. Start a script (personally I'd go for Python) that will do the migration work.启动一个脚本(我个人将 go 用于 Python)来完成迁移工作。
  4. Program the script to connect and run the SQL query, or can read a CSV file you create manually from step #1.编写脚本以连接并运行 SQL 查询,或者可以读取您从步骤 #1 手动创建的 CSV 文件。
  5. Program the script to use the details to determine the target-filename and the URL to download from.对脚本进行编程以使用详细信息来确定目标文件名和要从中下载的 URL。
  6. Program the script to download the file from the given URL, and place it on the hard drive with the proper name.编写脚本以从给定的 URL 下载文件,并将其放置在具有正确名称的硬盘驱动器上。 (In Python, you might use urllib .) (在 Python 中,您可以使用urllib 。)

Hopefully that will get you as far as a bunch of files categorized by "issue" like:希望这会让您了解一堆按“问题”分类的文件,例如:

issue123/Feasibility Test.xls
issue123/Billing Invoice.doc
issue456/Feasibility Test.xls

Thank you everyone.谢谢大家。 I was able to get what I needed using htmlunit and java to traverse a report I made of all change items with attachments, go to each one, copy the source code, traverse that to find instances of the download method, and copy the unique IDs of each attachment and build an.xls of all items and their attachments.我能够使用 htmlunit 和 java 来获得我需要的东西来遍历我制作的所有带有附件的更改项目的报告,go 到每个项目,复制源代码,遍历它以查找下载方法的实例,并复制唯一 ID每个附件,并构建所有项目及其附件的 an.xls。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM