关于“使用PythonCaller打开由FeatureWriter创建的HTML页面”的答案 https://knowledge.亚搏在线safe.com/questions/31439/using-pythoncaller-to-open-html-page-created-by-fe.html 关于“使用PythonCaller打开由FeatureWriter创建的HTML页面”问题的最新答案 答案由david_r https://knowledge.亚搏在线safe.com/answers/31458/view.html

很高兴你成功了。作为参考,如果您需要查找任何文件的“URL”路径,只需将其拖放到浏览器中。然后您可以直接从地址栏中复制链接。

2016年7月21日星期四15:38:51 GMT david_r
答案由geospatiallover https://knowledge.亚搏在线safe.com/answers/31455/view.html

@david_r,我也发现了这个链接,在令人沮丧地尝试了所有可能的网络共享路径组合之后,我几乎放弃了这个链接。我放弃了PythonCaller,而是使用了您建议的关机脚本,然后在那个链接上使用了示例代码。

这是我最后的代码,其中也包括我的路径

进口fme
进口fmeobjects

导入web浏览器
如果可能的话,在一个新选项卡中打开2 #

打开一个公共URL,在本例中是webbrowser docs
# url = "http://docs.python.org/library/webbrowser.html
# webbrowser.open (url,新的=)

在我自己的(Windows)电脑上打开一个HTML文件
url = " file: / / / / / H: / 2016 / DGN_Conversions /解决方案/输出/ HelloWorld.html”
webbrowser.open (url,新的=)

非常感谢……现在,我必须学习HTMLReportGenerator,然后测试文件和路径转换器,以参数化路径后,功能作家创建我的html在关机脚本中使用。

格林尼治时间2016年7月21日星期四15:24:13 geospatiallover
答案由geospatiallover https://knowledge.亚搏在线safe.com/answers/31443/view.html

我通过将代码插入def processFeature(默认情况下由PythonCaller提供)中来修复了这个致命的错误。

该网址仍然没有打开,但好在我的翻译没有失败。

def processFeature(feature): response = urllib2.urlopen('file:////alxapfs23/RSALVALE$/2016/DGN_Conversions/Solution/output/Helloworld.htm') html = response.read()通过
2016年7月21日星期四12:52:45 GMT geospatiallover
答案由geospatiallover https://knowledge.亚搏在线safe.com/answers/31441/view.html

谢谢你的快速回复。

在我读你的建议之前,我尝试使用网络共享路径的html文件:

进口urllib urllib.request.urlopen (“/ / alxapfs23 / RSALVALE美元/ 2016 / DGN_Conversions /解决方案/输出/ Helloworld.htm”) .read ()

我得到了这个错误:

2016-07-21 07:20:09| 1.2| 0.1|错误|Python异常
       
        : 'module'对象没有属性'request' 2016-07-21 07:20:09| 1.2| 0.0|错误|回溯(最近一次调用):File "
        
         ,在第三行
         
          AttributeError:“模块”对象没有属性“请求”2016-07-21 07:20:09 | 1.2 | 0.0 | |错误错误执行字符串“进口urllib urllib.request.urlopen (" / / alxapfs23 RSALVALE美元/ 2016 / DGN_Conversions /解决方案/输出/ Helloworld.htm”) .read()的2016-07-21 07:20:09 | | 1.2 | 0.0 |致命的工厂代理没有初始化2016-07-21 07:20:09 | 1.2 | 0.0 | |致命f_17 (PythonFactory): PythonFactory未能过程特性2016-07-21 07:20:09 | 1.2 | 0.0 | |错误BADNEWS:发生了一个致命错误。检查日志文件上面的细节(dynafact.cpp: 315) 2016-07-21 07:20:09 | 1.2 | 0.0 |通知| = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - 2016-07-21 07:20:09 | 1.2 | 0.0 |通知|特性输出统计FFS的作家使用关键字“W_1”:2016-07-21 07:20:09| 1.2| 0.0|STATS |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 2016-07-21 07:20:09| 1.2| 0.0|STATS | Features Written 2016-07-21 07:20:09| 1.2| 0.0|STATS |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 2016-07-21 07:20:09| 1.2| 0.0|STATS |============================================================================== 2016-07-21 07:20:09| 1.2| 0.0|STATS |Total Features Written 0 2016-07-21 07:20:09| 1.2| 0.0|STATS |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 2016-07-21 07:20:09| 1.2| 0.0|ERROR |A fatal error has occurred.检查日志文件详情2016-07-21以上07:20:09 | 1.2 | 0.0 | |错误(stftrans.cpp: 293)——(simptran.cpp: 769)——(stftrans.cpp: 323)——(pipeline.cpp: 992)——(fctwriter.cpp: 673)——(fctwriter.cpp: 697)——(factory.cpp: 1183) - (. . \ . . \ \ framework \基础引擎\ stfspec.h: 229) - (factory.cpp: 1146) (pipeline.cpp: 1149)——(pipeline.cpp: 760) - (. . \ . . \ \ framework \基础引擎\ stfspec.h: 229) - (factory.cpp: 539) (fcttee.cpp: 232)——(fcttee.cpp: 259) - (. . \ . . \ \ framework \基础引擎\ stfspec.h: 229)(factory.cpp: 1146) - (pipeline.cpp: 1149) (pipeline.cpp: 760) - (. . \ . . \ \ framework \基础引擎\ stfspec.h: 229) - (factory.cpp: 539) (fcttee.cpp: 239)——(fcttee.cpp: 259) - (. . \ . . \ \ framework \基础引擎\ stfspec.h: 229) - (factory.cpp: 1146) (pipeline.cpp: 1149)——(pipeline.cpp: 765)——(factory.cpp: 539)——(fctcreat.cpp: 500)——(factory.cpp: 1146)——(pipeline.cpp: 1149)——(pipeline.cpp: 760) - (. . \ . . \ \ framework \基础引擎\ stfspec.h: 229) - (factory.cpp: 539) (dynafact.cpp: 315) 2016-07-2107:20:09| 1.2| 0.0|通知|FME会话时长:1.4秒。(CPU: 0.5s用户,0.4s系统)2016-07-21 07:20:09| 1.2| 0.0|通知|结束进程d: 12844,峰值进程内存使用量:72108 kB,当前进程内存使用量:72104 kB
         
        
       
2016年7月21日星期四12:17:27 GMT geospatiallover
答案由david_r https://knowledge.亚搏在线safe.com/answers/31440/view.html

如果您需要在页面写完之后访问它,那么关闭脚本可能会比PythonCaller工作得更好,但是原理是一样的。

这两个模块应该给你一个很好的起点:

打开URL资源:urllib2教程

对于解析HTML,这里有一种方法:HTMLParser

大量的例子,如果你谷歌一点。

格林尼治时间2016年7月21日星期四12:07:06 david_r