我想使用Python从一堆包含硬编码数据的javascript文件中将以下所示的数据行提取到一个csv文件中,如下所示:
.... html代码...
hotels [0] = new hotelData();
hotels [0] .hotelName =“ MANHATTAN”;
hotels [0] .hotelPhone =“”;
hotels [0] .hotelSalesPhone =“”;
hotels [0] .hotelPhone ='Phone:888-350-6432
';
hotels [0] .hotelStreet =“ 787 11TH AVENUE”;
hotels [0] .hotelCity =“纽约”;
hotels [0] .hotelState =“ NY”;
hotels [0] .hotelZip =“ 10019”;
hotels [0] .hotelId =“ 51543”;
hotels [0] .hotelLat =“ 40.7686” ;;
hotels [0] .hotelLong =“ -73.992645” ;;
hotels [1] = new hotelData();
hotels [1] .hotelName =“ KOEPPEL”;
hotels [1] .hotelPhone =“”;
hotels [1] .hotelSalesPhone =“”;
hotels [1] .hotelPhone ='电话:718-721-9100
';
hotels [1] .hotelStreet =“ 57-01 NORTHERN BLVD。”;
hotels [1] .hotelCity =“ WOODSIDE”;
hotels [1] .hotelState =“ NY”;
hotels [1] .hotelZip =“ 11377”;
hotels [1] .hotelId =“ 51582”;
hotels [1] .hotelLat =“ 40.75362” ;;
hotels [1] .hotelLong =“ -73.90366” ;;
var mykey =“ AlvQ9gNhp7oNuvjhkalD4OWVs_9LvGHg0ZLG9cWwRdAUbsy-ZIW1N9uVSU0V4X-8”;
var map = null;
var pins = null;
var i = null;
var box = new Array();
var currentBox = null;
var mapOptions = {
凭据:mykey,
enableSearchLogo:否,
showMapTypeSelector:否,
enableClickableLogo:否
}
..... html代码.....
因此,所需的csv输出将类似于上述数据的行:
曼哈顿,电话:888-350-6432 ...
KOEPPEL``电话:718-721-9100 ...
我是否应该使用代码生成工具直接解析以上语句以获取数据?哪一种最有效的Python方法可将数千个Javascript文件中包含的此类数据转换为csv表格格式?
慕虎7371278
万千封印
相关分类