jython研究笔记
- jython目前只支持python2,不支持python3.
- 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研究笔记的更多相关文章
- jython安装与配置
安装jython 0. 计算机中要安装jdk 1. 在官网www.jython.org上找到下载页面,然后下载jython-installe 2. 在cmd.exe中运行java -jar jytho ...
- jython安装
下载了jython后:http://www.cr173.com/soft/9719.html 这是我当时下载的网站 官网很慢开始->运行->cmd->打开dos命令窗口,转到jyth ...
- jython 2.7 b3发布
Jython 2.7b3 Bugs Fixed - [ 2108 ] Cannot set attribute to instances of AST/PythonTree (blocks pyfla ...
- 基于jython操作hbase
一.前言 关于jython介绍,直接上官网www.jython.org,可以得到详细资料,这里只介绍一下jython操作hbase的一些方法,本质上和用java操作hbase差不多,只不过语法换成了p ...
- Jython概要
1.安装jython 1.1 进入http://www.jython.org/downloads.html ,网页上会显示当前最稳定的版本(The most current stable releas ...
- jython学习笔记3
1.os.environ["HOME"] 为什么这句话在我的STS中打印不出东西,还报错 Method Description close() Close file fileno( ...
- jython语言学习笔记
1.变量可以随便定义,不限制类型,不限制数值.开头空4个空格,使用def定义函数,可以嵌套,可以传参. 2.每个语句结束的时候没有分号.定义类的时候没有括号.在print语句的后面有格式转换时要加上% ...
- Jython安装步骤
1.下载安装包 2.执行安装 Java -jar [此处是下载的jython jar包名],或者双击jar包夜可以 3.配置环境变量 新增JYTHON_THOME的环境变量,并设置为安装路径. 配置c ...
- JDK和Jython安装
下载JAVA SE,下载地址请到oracle官方网站下载. JDK下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8- ...
随机推荐
- luogu P1192 台阶问题
https://www.luogu.org/problem/show?pid=1192 登楼梯 肯定能想到 dp[i] = dp[i-1] + dp[i-2] + ...+ dp[i-k] 然后想到 ...
- python find 返回元素的索引
As it turns out, there is a string method named find that is remarkably similar to the function we w ...
- python 操作Excel表格,解压zip包,压缩zip包,目录遍历
import zipfile import os,shutil import openpyxl file_list_pos="" fileName="" zip ...
- 流行得前端构建工具比较,以及gulp配置
前端现在三足鼎立的构建工具(不算比较老的ant,yeoman),非fis,grunt,gulp莫属了. fis用起来最简单,我打算自己得项目中使用一下fis. 先说一下gulp安装吧. 第一步:安装n ...
- Mysql中FIND_IN_SET和REPLACE函数简介
一 FIND_IN_SET() SELECT * from u_user where FIND_IN_SET('32',tags) 上面的sql是精确查找,查找表中tags中含有32的记录(注意这里 ...
- rails安装使用版本控制器的原因。
使用版本控制器的原因: 你没有系统根权限,所以你没有别的选择 你想要分开运行几个rails 系统 ,并且这几个rails有不同的Ruby版本.使用RVM就可以轻松做到. 没有什么新鲜的先安装xcode ...
- Spring学习笔记1——基础知识
1.在java开发领域,Spring相对于EJB来说是一种轻量级的,非侵入性的Java开发框架,曾经有两本很畅销的书<Expert one-on-one J2EE Design and Deve ...
- 2-3-2 rsync+inotify备份同步数据
RSYNC = Remote Sync 远程同步 高效,一定要结合shell 官网:https://rsync.samba.org Author: Andrew Tridgell, Wayne Dav ...
- Invalid bound statement (not found)错误的可能原因
其他原因导致此问题解决参考: 1.检查xml文件所在package名称是否和Mapper interface所在的包名 <mapper namespace="me.tspace.pm. ...
- vuex: 简单(弹窗)实现
在使用基于 vue.js 2.0 的UI框架 ElementUI 开发网站的时候 , 就遇到了这种问题 : 一个页面有很多表单 , 我试图将表单写成一个单文件组件 , 但是表单 ( 子组件 ) 里的数 ...