1. jython目前只支持python2,不支持python3.
  2. python中使用第三方包的话需要重新设置lib的地址。
public void getHtmlByTxt(String path) {
// TODO 编写调用python抓取页面的程序
PySystemState sys = Py.getSystemState();
sys.path.add("D:\\Python\\Python36\\Lib\\site-packages\\");
PythonInterpreter interpreter = new PythonInterpreter();
String pyPath = this.getClass().getResource("/py/game.py").getPath().substring(1);
//String pyPath = this.getClass().getClassLoader().getResource("py/game.py").getPath();
logger.info(pyPath);
interpreter.exec("import sys");
interpreter.execfile(pyPath);
}
# coding=utf-8
import io
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities if __name__ == '__main__':
url = "http://data.champdas.com/match/data-10258.html"
dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0 ") obj = webdriver.PhantomJS(executable_path=r'D:\phantomjs\bin\phantomjs.exe',desired_capabilities=dcap)
obj.get(url)
html = obj.page_source
obj.quit() fw = open("D:\\test.html","w", encoding='utf-8')
fw.write(html)
fw.close()

jython研究笔记的更多相关文章

  1. jython安装与配置

    安装jython 0. 计算机中要安装jdk 1. 在官网www.jython.org上找到下载页面,然后下载jython-installe 2. 在cmd.exe中运行java -jar jytho ...

  2. jython安装

    下载了jython后:http://www.cr173.com/soft/9719.html 这是我当时下载的网站 官网很慢开始->运行->cmd->打开dos命令窗口,转到jyth ...

  3. jython 2.7 b3发布

    Jython 2.7b3 Bugs Fixed - [ 2108 ] Cannot set attribute to instances of AST/PythonTree (blocks pyfla ...

  4. 基于jython操作hbase

    一.前言 关于jython介绍,直接上官网www.jython.org,可以得到详细资料,这里只介绍一下jython操作hbase的一些方法,本质上和用java操作hbase差不多,只不过语法换成了p ...

  5. Jython概要

    1.安装jython 1.1 进入http://www.jython.org/downloads.html ,网页上会显示当前最稳定的版本(The most current stable releas ...

  6. jython学习笔记3

    1.os.environ["HOME"] 为什么这句话在我的STS中打印不出东西,还报错 Method Description close() Close file fileno( ...

  7. jython语言学习笔记

    1.变量可以随便定义,不限制类型,不限制数值.开头空4个空格,使用def定义函数,可以嵌套,可以传参. 2.每个语句结束的时候没有分号.定义类的时候没有括号.在print语句的后面有格式转换时要加上% ...

  8. Jython安装步骤

    1.下载安装包 2.执行安装 Java -jar [此处是下载的jython jar包名],或者双击jar包夜可以 3.配置环境变量 新增JYTHON_THOME的环境变量,并设置为安装路径. 配置c ...

  9. JDK和Jython安装

    下载JAVA SE,下载地址请到oracle官方网站下载. JDK下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8- ...

随机推荐

  1. TypeScript 照猫画虎

    定义变量类型 const num: number = 1 定义函数参数类型 const init: (p: str) => void = function(param) { alert(para ...

  2. Elasticsearch之中文分词器插件es-ik(博主推荐)

    前提 什么是倒排索引? Elasticsearch之分词器的作用 Elasticsearch之分词器的工作流程 Elasticsearch之停用词 Elasticsearch之中文分词器 Elasti ...

  3. 解决 docker: Error response from daemon: ... : net/http: TLS handshake timeout.

    参考:解决 Docker pull 出现的net/http: TLS handshake timeout 的一个办法 问题: 执行 $ sudo docker run hello-world 时出现: ...

  4. 51 Nod 1500 苹果曼和树(树形dp)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1500 思路: 树形dp. 我们考虑当前结点 i ,对于结点 i ,它可以 ...

  5. POJ 2391 Ombrophobic Bovines(二分+拆点+最大流)

    http://poj.org/problem?id=2391 题意: 给定一个无向图,点i处有Ai头牛,点i处的牛棚能容纳Bi头牛,求一个最短时间T,使得在T时间内所有的牛都能进到某一牛棚里去. 思路 ...

  6. Codeforces Round #278 (Div. 2) D. Strip 线段树优化dp

    D. Strip time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  7. a标签 在新页面打开

    <a href="https://www.baidu.com/" target="_blank">下载</a>

  8. Postman模拟高并发执行

    一次,执行1000次. 看看服务器能否承受住. 查看每一次的执行情况,查看总的执行情况.成功情况,失败情况.

  9. python 数字的四舍五入的问题

    由于 python3 包括python2.7 以后的round策略使用的是decimal.ROUND_HALF_EVEN 即Round to nearest with ties going to ne ...

  10. 雷林鹏分享:Ruby 数组(Array)

    Ruby 数组(Array) Ruby 数组是任何对象的有序的.整数索引的集合.数组中的每个元素都与一个索引相关,并可通过索引进行获取. 数组的索引从 0 开始,这与 C 或 Java 中一样.一个负 ...