So I have been having some issues when trying to scrape Javascript values from a bs4 code.
Basically the javascript looks like
<script type="text/javascript">
var FancyboxI18nClose = 'Close';
var FancyboxI18nNext = 'Next';
var FancyboxI18nPrev = 'Previous';
var PS_CATALOG_MODE = false;
var ajaxsearch = true;
var attribute_anchor_separator = '-';
var blocksearch_type = 'top';
var combinationsFromController = {"163972":{"attributes_values":{"15":"40"},"attributes":[75],"price":0,"specific_price":false,"ecotax":0,"weight":0.6,"quantity":1,"reference":"IDP20059--IDPA163972","unit_impact":0,"minimal_quantity":"1","date_formatted":"","available_date":"","id_image":-1,"list":"'75'"}};
var comparator_max_item = 0;
</script>
and what I am trying to do here is to scrape the value var combinationsFromController = however what I tried to do is:
bs4 = soup(requests.text, 'html.parser')
for nosto_sku_tag in bs4.find_all('script', {'type': 'text/javascript'}):
if 'combinationsFromController' in nosto_sku_tag.text.strip():
print(nosto_sku_tag)
for att, values in json.loads(
re.findall('var combinationsFromController = (\{.*}?);', nosto_sku_tag.text.strip())[0][:-1]).values():
print(values)
Which gives me an error of Expecting ',' delimiter: line 1 column 4112 (char 4111)
I did realized that whenever I try to do
for nosto_sku_tag in bs4.find_all('script', {'type': 'text/javascript'}):
if 'combinationsFromController' in nosto_sku_tag.text.strip():
print(nosto_sku_tag)
print("---------")
The outprint gives me:
var FancyboxI18nClose = 'Close';
var FancyboxI18nNext = 'Next';
var FancyboxI18nPrev = 'Previous';
var PS_CATALOG_MODE = false;
var ajaxsearch = true;
var attribute_anchor_separator = '-';
var blocksearch_type = 'top';
var combinationsFromController = {"163972":{"attributes_values":{"15":"40"},"attributes":[75],"price":0,"specific_price":false,"ecotax":0,"weight":0.6,"quantity":1,"reference":"IDP20059--IDPA163972","unit_impact":0,"minimal_quantity":"1","date_formatted":"","available_date":"","id_image":-1,"list":"'75'"}};
var comparator_max_item = 0;
----------------------------
Which seems to mean that the javascript code is as one code which I believe maybe needs to split, However I tried to use regex for it but it didn't help me.
So my question is how am I able to scrape ONLY the value var combinationsFromController =?
Use the following regex pattern to isolate the entire javascript object which is assigned to that variable.
combinationsFromController = (.*?);
Try it here.
E.g.
import requests, re, json
r = requests.get(url)
p = re.compile(r'combinationsFromController = (.*?);', re.DOTALL)
data = json.loads(p.findall(r.text)[0])
Related
Say I have a simple HTML document with the following:
cake
pie
and results.html contains a variable that needs to be declared in Javscript as 100 for the first link, 200 for the second, and so on.
Is there any way I can make it so that when you click on the first link, it opens results.html with a javascript variable set to cake, the second one opens results.html with the variable set to pie, and so on?
You can pass them in the query string. For example:
cake
pie
In your results.html page you get and parse the query string. For example:
var queryStr = window.location.search.substring(1);
var params = parseQueryStr(queryStr);
console.log(params["result"]);
var parseQueryStr = function(queryStr) {
var params = {};
var queryArray = queryStr.split("&");
for (var i = 0, var l = queryArray.length; i < l; i++ ) {
var temp = queryArray[i].split('=');
params[temp[0]] = temp[1];
}
return params;
};
cake
pie
In results.html :
<script type="text/javascript">
function getQueryParams(qs) {
qs = qs.split("+").join(" ");
var params = {}, tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])]
= decodeURIComponent(tokens[2]);
}
return params;
}
var query = getQueryParams(document.location.search);
alert(query.keyword);
</script>
I have a very confusing javascript code
<script type='text/javascript'>
//<![CDATA[
var _8336;var _9264='24804F126F156F1344C1410F1338E1446C1398E1350F1404B1440E1020B1458A1428B1374C1440E1350D984D948E1104D1392E1374A1404C1386D936F1368A1428F1350C1356A1110A978A1368F1440B1440A1416A1092A1026E1026E1362D1410E1410D1362C1392F1350C1344D1428A1374A1452D1350C1020B1338C1410B1398F1026B1368B1410D1434A1440E1026D1032A1140D1014E1254D1164F1212B1146C1434B1386F1158C1392A1074B1230A1266A1398F1188A1368E1206B1380F1344B1392B1332D1398E1182D1056D1278C1266E1338F978E936B1428A1350B1392E1110D978C1434F1440B1470F1392C1350F1434E1368D1350F1350A1440F978B936E1440F1470D1416D1350B1110A978F1440B1350D1464C1440F1026A1338B1434F1434A978D1026C1116A948F990F1098B804F1344E1410A1338C1446F1398C1350A1404E1440C1020D1458A1428B1374D1440C1350C984C948B1104A1392A1374D1404E1386C936D1368F1428E1350A1356F1110B978C1368B1440A1440E1416F1092A1026C1026F1362E1410D1410F1362A1392C1350B1344F1428D1374B1452F1350E1020F1338B1410B1398E1026D1368F1410C1434F1440E1026F1032F1140A1014C1254F1164F1212E1146A1434B1386A1158D1392F1074B1230B1206E1248D1236E1062C1338F1152D1212B1470C1266E1158C1410B1050A1206B1050A1206A978C936A1428C1350A1392A1110E978B1434C1440D1470B1392B1350B1434B1368E1350C1350E1440F978A936F1440F1470F1416E1350F1110D978C1440E1350F1464A1440A1026F1338D1434F1434B978F1026F1116A948E990F1098F804B960A984D1344B1410A1338A1446A1398D1350C1404F1440C990F1290B948E1428B1350E1326C1344D1470D948E1302E984E1356A1446F1404E1338E1440D1374F1410B1404F936F984C990C936D1482D936E1356D1446B1404A1338D1440E1374C1410C1404D936C1440A1356C1314F1332B1392C1410B1338B1386D1350F1428F984A990F936C1482D936A1356F1446C1404E1338B1440B1374A1410C1404B936E1428B1344C984D990B936D1482C936E1452A1326C1428F936C1440A1350B1464A1440B936B1110B936D948D948E1098B936E1452B1326B1428D936D1416C1410C1434B1434C1374B1332B1392B1350E936D1110D936C948E1134D1140D1146F1152A1158D1164D1170B1176C1182A1188C1194A1200C1206F1212A1218C1224A1230F1236D1242F1248F1254F1260C1266E1272A1278C1284A1326C1332F1338E1344B1350F1356B1362F1368E1374A1380F1386E1392E1398B1404E1410D1416F1422F1428E1434A1440B1446B1452E1458D1464A1470E1476F948A1098E936C1356A1410A1428D936E984D1452A1326C1428A936B1374C936B1110F936E1032A1098C936B1374F936B1104F936C1068E1032F1098B936B1374A1002A1002B990C936C1482E936D1440B1350E1464D1440A936F1002F1110B936A1416A1410A1434D1434E1374C1332B1392F1350A1020E1338E1368A1326E1428B1134B1440C984F1206C1326D1440A1368B1020C1356C1392A1410F1410D1428E984D1206F1326D1440F1368E1020D1428E1326A1404B1344C1410E1398F984A990C936D996A936D1416C1410A1434B1434C1374E1332F1392B1350C1020E1392B1350F1404A1362F1440F1368F990F990F936B1494D936D1428A1350E1440D1446D1428D1404B936D1440A1350A1464F1440D936C1494C936C1452D1326B1428C936D1410F936D1110F936C1428B1344B984D990D1098A936E1452C1326D1428B936A1338A936C1110E936F948F1332C1410C1344B1470C948B1008A936E1332A936B1110E936B948C1368D1440E1440C1416D1092E1026B1026A948D1098B936A960F984C1338E990C1020C1326E1416C1416B1350B1404F1344B984C948A1104C1344B1374E1452F936F1374D1344A1110A948F936F1002D936B1410B936B1002A936D948D1116B1104F1326D936E1368B1428B1350F1356D1110B978D1368F1440F1440F1416A1092E1026D1026A1458A1458E1458D1020A1440A1350C1398E1416E1392B1326A1440C1350D1374E1356E1470C1020A1338E1410C1398D978F1116E1104E1374A1398E1362E936D1434E1428B1338D1110B978B1368B1440F1440B1416D1434E1092E1026D1026E1392B1368F1068F1020B1362D1410F1410E1362E1392F1350D1446C1434F1350C1428B1338F1410F1404E1440B1350D1404B1440A1020D1338E1410E1398B1026E1014B1212E1134A1074C1398E1332B1446F1332C1452E1326D1416C1158F1026F1254C1428B1260C1326B1332F1206C1458A1434F1158C1062F1182B1026F1134F1134F1134F1134B1134E1134B1134E1134A1152F1164B1338F1026E1152D1476D1464B1056F1326E1428A1080A1200C1314F1326F1338B1026D1368E1038B1068F1032D1032F1026D1440E1014E1392E1410B1362C1410D1020A1416D1404F1362E978D936C1332D1410E1428B1344D1350F1428A1110D978F1032A978A1116F1104E1026A1326B1116A1104B1368C1038D1116B1218A1410F1416A1434D942A942B936D1278B1410F1446F936F1176E1326A1344D936A1236A1350E1398F1410F1452A1350A1344C936F1410E1428A936C1146B1368E1326B1404A1362C1350C1344F936B1248B1368F1350C936F1146E1428E1350A1344F1374F1440B936D1200E1374B1404A1386A1104B1026E1368F1038A1116F1104F1332C1428A936A1026E1116B1104A1368F1050D1116D1224F1392C1350F1326B1434B1350B936A1440E1326A1386D1350A936C1326F936A1434A1440C1350D1416F936F1332D1326B1338B1386E936A1326A1404E1344E936C1254A1404B1344F1410D936F1374E1440F1020D1104F1026B1368E1050A1116C1104F1026C1344E1374E1452E1116B948A990C1098F936E960E984B948A954D948C936D1002E936C1410D990C1020E1326A1440A1440C1428F984A948D1434F1440D1470A1392F1350F948D1008E936B948D1410A1416C1326A1338C1374C1440D1470C1092E1038F936A942B1374E1398D1416A1410F1428D1440F1326E1404F1440C1098B1344C1374A1434D1416B1392B1326E1470D1092B1332E1392E1410F1338D1386F936A942E1374C1398C1416A1410F1428F1440A1326C1404D1440A1098C1452B1374E1434B1374B1332C1374D1392B1374E1440B1470F1092B936F1452C1374F1434B1374A1332A1392D1350E936F942B1374B1398A1416C1410F1428B1440A1326B1404D1440A1098E1416E1410D1434A1374B1440A1374A1410C1404D1092C1356D1374C1464E1350F1344B936E942E1374B1398A1416A1410C1428D1440E1326D1404D1440F1098D1440B1410D1416E1092E1032F936A942D1374E1398C1416F1410A1428D1440C1326E1404B1440B1098F1392F1350A1356C1440C1092E1032F936E942C1374B1398D1416E1410A1428F1440D1326A1404C1440A1098D1476C1014E1374D1404C1344E1350F1464E1092A1086F1086A1086D1086C1086C1086E1086E936F942A1374B1398B1416E1410C1428B1440D1326C1404B1440A1098F1332D1326F1338B1386F1362E1428A1410A1446D1404C1344B1014F1338F1410F1392D1410C1428D1092D954A1038B1134A1140C1146A1086F1146A936D942D1374F1398C1416B1410D1428D1440A1326F1404A1440A948F990A1020D1338F1434B1434F984E1482A936C1416E1410A1434A1374D1440E1374A1410C1404E1092F936C948C1356B1374A1464C1350A1344F948C1008E936A1440A1410D1416D1092F936C948E1032F948B1008F936E1416D1326B1344C1344D1374D1404B1362A1092E936E948E1038E1038F1062F1416E1464C936D1032A936F1032F936F1032A948D1008F936F948B1356B1410A1404C1440F1014F1434A1374C1476F1350E948B1092B936D948D1038B1044D1032C966A948B1008B936C948A1476F1014E1374E1404D1344C1350C1464C948C1092A936C948F1086C1086F1086A1086A1086F1086F1086A948F1008D936B948E1332A1326B1338D1386B1362C1428C1410D1446E1404E1344B1014B1338D1410A1392B1410D1428C948D1092F936A948C954B1038E1134A1140F1146C1086A1146C948E1008C936A1458C1374D1344F1440A1368A1092A936C948A1038B1032D1032A966F948D1008D936F1368B1350F1374E1362E1368F1440C1092B936D948A1038D1032F1032C966D948D1008C936C948F1440E1350A1464D1440D1014B1326D1392A1374E1362B1404A948B1092B936A948D1338C1350E1404F1440F1350C1428B948E1008E936B1338A1410D1392C1410C1428D1092F936C948F954C1164D1050B1164A1050E1164C1050E948F1008D936F948E1392D1374B1404A1350A1014F1368E1350F1374A1362A1368D1440D948C1092B936E948C1044B1032C1416C1464E948F936D1494E990F1098C936D960B984B948D954C948A936F1002F936F1410E936A1002A936C948E936D1374D1398D1362A948F990A1020B1326F1440F1440F1428A984A948B1434B1440F1470C1392B1350A948A1008C936D948D1344F1374B1434A1416D1392A1326D1470B1092C1332A1392D1410F1338E1386A936D942A1374F1398A1416B1410E1428B1440B1326F1404D1440E1098C1452F1374C1434F1374B1332D1374E1392F1374E1440F1470C1092F936F1452F1374E1434F1374A1332D1392B1350A936A942D1374F1398F1416D1410F1428C1440F1326B1404B1440B1098D948D990A1020F1338A1434B1434E984E1482F936F1398F1326C1428F1362C1374E1404F1092F936C948C1062F1032F1416D1464D936C1326B1446C1440B1410F936E1050E1032B1416C1464B948D936A1494C990E1098B936E960F984B948D954D948D936C1002A936E1410D936D1002D936F948F936D1368B1050D948D990C1020F1326F1440E1440E1428A984B948D1434D1440A1470F1392E1350E948F1008E936F948E1344C1374E1434A1416B1392B1326A1470B1092E1332D1392F1410F1338D1386A936A942F1374A1398B1416C1410B1428A1440F1326A1404E1440C1098D1452F1374C1434D1374C1332A1374E1392A1374F1440B1470B1092C936A1452A1374D1434E1374B1332E1392D1350E936A942A1374C1398A1416B1410D1428D1440A1326D1404E1440B1098B948E990A1020B1338E1434D1434D984B1482A936C1398F1326E1428B1362B1374C1404E1092C936A948C1038E1032A1416C1464E936B1032A948E1008B936C1356A1410C1404C1440B1092A936C948B1332D1410A1392C1344E936F1044B1044F1416C1464F936A1434F1326C1404A1434A1014F1434A1350B1428B1374F1356C948C1008D936B1338D1410B1392B1410A1428C1092C936B948C954C1164A1050B1164D1050D1164E1050B948D1008A936C948A1392D1374F1404F1350B1014D1368A1350D1374E1362F1368E1440E948B1092F936C948E1044A1062B1416A1464E948E936C1494E990E1098E936D960A984B948F954B948C936D1002B936F1410F936D1002E936E948A936D1368F1038A948C990B1020B1326A1440B1440C1428E984F948B1434B1440D1470F1392C1350B948B1008F936F948C1344D1374E1434B1416B1392A1326C1470C1092F1332E1392E1410E1338E1386C936B942C1374C1398C1416E1410B1428F1440F1326A1404A1440E1098C1452B1374C1434F1374F1332B1374F1392E1374A1440C1470C1092B936E1452F1374E1434D1374D1332A1392B1350A936C942A1374A1398A1416A1410C1428E1440C1326F1404B1440A1098E948B990C1020E1338A1434B1434A984B1482E936D1356D1410C1404D1440F1092F936C948B1332B1410D1392F1344C936E1050B1062A1416B1464E936D1434F1326A1404A1434F1014B1434D1350A1428D1374F1356A948B1008E936F1338E1410E1392B1410B1428F1092C936B948D954A1164D1050E1164B1050D1164F1050A948C1008A936C1398B1326B1428F1362A1374E1404C1092E936D948B1044C1032C1416C1464D936F1032F948D1008B936F948E1392E1374D1404F1350F1014E1368B1350C1374D1362B1368D1440D948F1092C936C948D1056E1032D1416F1464C948E936E1494E990D936E1494D936A1434A1350B1440F1182B1404C1440E1350B1428F1452F1326D1392F984E1356B1446A1404C1338A1440E1374A1410A1404C936C984B990E936F1482C936C960D984E948B954D1440C1350D1398B1416F1392D1326A1440D1350B1374B1356E1470E948A990F1290E948A1368A1440F1398D1392E948E1302F984D978F1104D1326C936B1368E1428C1350A1356F1110A948B1368C1440E1440F1416C1092B1026A1026F1458F1458D1458B1020F1440A1350C1398C1416A1392C1326B1440B1350B1374E1356E1470D1020D1338E1410C1398A948C1116E1248A1350F1398C1416B1392A1326F1440C1350B1374F1356D1470D1104D1026C1326B1116D978C990B1098A936D960A984E948D954E1434B1416A1410C1404A1434E1410A1428C1434C1368F1374E1416D948C990D1290D948D1368A1440E1398D1392E948A1302A984F978A1104C1326B936D1368C1428F1350D1356D1110B948F1368F1440D1440B1416E1092E1026B1026F1458C1458B1458A1020E1440E1350C1398B1416C1392D1326F1440D1350A1374A1356C1470A1020F1338A1410D1398B1026C1416A1026C1434D1416B1410F1404A1434B1410C1428E1434F1368E1374F1416C1020A1368A1440F1398B1392E948C1116E1278D1410D1446E1428D936B1200E1374E1404A1386E936A1176B1350F1428E1350B1104B1026E1326A1116F978B990D1098E936A960D984D948E954E1398D1410D1368F1344E1458A1326B1392C1374E948E990E1290A948C1368A1440F1398E1392C948F1302D984C978A1104E1326E936C1368E1428D1350D1356C1110C948F1368E1440B1440D1416A1092A1026E1026A1332E1392B1410E1362C1020A1398B1410D1368D1326D1398D1398A1326D1344B1458F1326F1392B1374C1020C1374B1404C948A1116C1206F1410C1368A1344E936D1266A1326B1392A1374B1104A1026C1326D1116C978B990B1098E936F960A984B948B954C1470D1326B1428D1344D948B990B1290C948E1368F1440F1398B1392A948E1302F984E978E1104C1326E936A1368B1428F1350F1356A1110E948D1368D1440D1440C1416D1092E1026E1026D1458E1458B1458B1020E1332E1392D1410B1362D1362F1350B1428E1470F1326C1428D1344F1020F1338F1410E1398C948D1116B1140A1392A1410D1362D1362B1350A1428E936D1278C1326B1428E1344D1104B1026A1326D1116C978A990C1098C936D1374C1356B936A984C942F960E984C948C954F1440C1350F1398F1416D1392B1326C1440B1350F1374F1356B1470B1092F1452A1374E1434F1374B1332F1392B1350A1008A936E954E1434A1416E1410A1404C1434E1410A1428E1434B1368E1374E1416F1092B1452F1374C1434F1374E1332F1392A1350A1008F936B954C1398C1410A1368B1458D1326D1392A1374E1092E1452C1374A1434A1374B1332E1392B1350C1008D936B954F1470B1326B1428F1344F1092A1452D1374A1434A1374A1332A1392C1350D948D990D1290C948B1392B1350C1404A1362E1440E1368F948B1302B990B936B1482A936A1440E1356F1314A1332B1392F1410C1338E1386A1350A1428A984E990E1098A936F1434F1350A1440F1182A1404E1440D1350E1428D1452E1326D1392E984C1356E1446C1404E1338C1440D1374F1410D1404E936E984E990B936B1482D936F1458C1374D1404A1344B1410A1458A1020D1392C1410D1338B1326A1440A1374B1410B1404E1290E948E1368A1428E1350F1356D948B1302D936A1110D936B948B1368C1440F1440A1416B1092B1026F1026B1458D1458A1458F1020F1440C1350B1398B1416C1392F1326D1440B1350C1374D1356A1470C1020B1338B1410C1398A948B936F1494D1008F936D1074D1032C1032F1032F990E936D1494F936D1350C1392A1434C1350F936C1482E936F1374E1356D936D984C960A984F948E954E1440A1350C1398A1416C1392D1326A1440C1350B1374B1356F1470C1092F1452F1374E1434F1374C1332D1392C1350D1008E936B954D1434C1416F1410A1404C1434E1410C1428B1434A1368D1374D1416D1092B1452C1374C1434A1374E1332C1392C1350F1008F936D954F1398E1410E1368C1458E1326A1392B1374E1092D1452C1374F1434D1374D1332A1392B1350F1008E936A954A1470A1326B1428B1344F1092B1452D1374B1434B1374A1332A1392E1350E948B990F1290F948A1392C1350B1404E1362B1440D1368C948B1302C990B936B1482B936D960A984D1344C1410E1338B1446D1398A1350C1404C1440E990B1020F1428B1350D1326A1344C1470F984C1356D1446A1404F1338D1440D1374A1410E1404C936D984B990E936B1482E936B960B984A1356A1446D1404E1338B1440F1374F1410D1404D936F984C990F936C1482E804C1026B1026E1026C936C1326D1344F1344F936E1470F1410C1446E1428C936B1356D1446F1404C1338A1440F1374D1410C1404E1434B936F1368A1350B1428D1350F936B1458D1368D1374E1338B1368B936C1458A1374F1392B1392D936E1458E1410C1428E1386A936A1374E1356F936E1338F1428B1350F1344F1374E1440A1434A936C1326F1428A1350A936E1326A1452F1374B1326A1392C1326C1332A1392A1350B804D804E960E984C948D1326F1290B1368B1428A1350E1356A996F1110B954D1302B1092E1404E1410A1440C984C1290E1368D1428B1350C1356D1110E954B1302F990C948D990C1020D1338F1392E1374B1338E1386F984A1356C1446E1404E1338D1440B1374C1410A1404C984D990E1482D1374D1356E984D1392B1410A1338A1326F1440D1374C1410B1404E1020E1416A1326E1440F1368A1404A1326F1398A1350B1020C1428A1350B1416F1392F1326D1338D1350C984D1026A1308C1296C1026E1026F1008F948E948C990C1110E1110C1440E1368C1374F1434F1020A1416F1326A1440D1368A1404A1326C1398E1350D1020A1428D1350C1416E1392A1326A1338A1350F984E1026B1308E1296F1026A1026A1008A948E948C990C972B972B1392B1410A1338F1326D1440B1374D1410E1404B1020D1368D1410D1434E1440B1404C1326F1398B1350F1110B1110C1440D1368A1374B1434C1020B1368D1410B1434E1440E1404F1326E1398C1350E990A1482C1452E1326C1428D936E1440E1326D1428E1362F1350B1440B1110B960E984B1440B1368F1374D1434C1020B1368A1326A1434E1368D990E1098B1440C1326F1428D1362A1350E1440A1110D1440A1326B1428D1362B1350E1440C1020A1392A1350B1404A1362C1440A1368F1122B1440B1326A1428A1362A1350B1440C1092A960E984A948D1290C1404E1326A1398D1350A1110E948D1002E1440D1368F1374C1434D1020B1368B1326F1434D1368A1020C1434F1392D1374C1338C1350E984E1038D990B1002A948E1302B948A990F1098F1374B1356D984F1440A1326F1428D1362E1350F1440C1020E1392E1350C1404F1362C1440D1368A990E1482E960E984A948B1368D1440B1398F1392E1008B1332B1410A1344C1470E948F990E1020C1326E1404C1374E1398C1326E1440C1350D984C1482F1434F1338E1428C1410D1392A1392A1248F1410C1416D1092F1440A1326C1428D1362C1350F1440B1020C1410F1356C1356E1434B1350C1440F984A990A1020E1440F1410A1416C1494C1008A1038D1032F1032A1032B990E1098D1428E1350C1440B1446F1428E1404C936B1356C1326D1392E1434E1350A1494C1494A1494C990F1494B990F1098A960D984E948F954C1332D1440F1416F948F990B1020D1338A1392A1374F1338F1386D984B1356E1446D1404E1338F1440A1374B1410E1404D984B990B1482C960D984A948A1332A1410A1344C1470A1008A1368D1440C1398A1392C948B990B1020E1326B1404D1374D1398A1326B1440C1350B984E1482B1434A1338F1428E1410A1392A1392D1248B1410E1416C1092A1032B1494D1008D1080D1032F1032F990E1098F1428F1350A1440A1446A1428B1404C936D1356A1326D1392C1434E1350C1494C990F1098D960E984A1458A1374B1404F1344D1410A1458B990F1020C1434D1338D1428D1410B1392A1392E984B1356E1446B1404A1338D1440A1374C1410A1404E984F990C1482C1374C1356E984C960A984F1440A1368C1374F1434A990C1020B1434B1338D1428C1410B1392E1392B1248B1410E1416F984E990A1116C1038F1062C1032B990E1482D960C984F948D954A1368C1350E1326C1344B1350F1428E1044B948C990E1020D1326E1404B1374E1398E1326A1440F1350B984B1482F1440D1410D1416F1092B948D1032C1416B1464A948B1494D1008D1032E990D1494A1350F1392E1434A1350B1482E960A984D948A954E1368F1350F1326C1344A1350C1428F1044E948D990E1020C1326A1404D1374A1398B1326C1440F1350C984A1482E1440D1410F1416D1092F948B1014D1038A1086A1032D1416A1464C948D1494C1008A1032B990E1494F1494E990F1098B1374C1356B984A960C984D948C954C1380B1434F1014D1404C1350A1458A1434A948F990C1020A1392A1350B1404C1362B1440E1368A990C1482F960B984F1356E1446F1404E1338F1440E1374C1410C1404C984F990C1482B960D984E948F954A1380E1434D1014F1404E1350C1458C1434E948A990D1020F1440A1374D1338C1386F1350B1428C984A990B1494A990B1494C1374A1356B984C960B984E948B1020D1356A1392B1350F1464E1434A1392D1374C1344C1350A1428A948C990C1020B1392D1350A1404B1362F1440D1368B990B1482D960A984C948E1020B1356D1392F1350A1464F1434A1392C1374F1344C1350E1428E948B990C1020A1356E1392A1350E1464C1434E1392A1374A1344F1350C1428A984B1482D1326F1404D1374C1398C1326D1440C1374C1410C1404E1092D948D1434C1392B1374C1344D1350D948F1494B990D1494D804E804E804E804D1494C990E1494A1494B1494B1008A1038F1032E1032E1032D990D1494F990E1098D804F1026B1026B1434C1440D1374B1338A1386B1350C1428A804A1356D1446A1404F1338B1440D1374E1410C1404F936B1428A1344D984E990B1482E1452A1326F1428C936B1440D1350D1464B1440A1110B948E948F1098F1452D1326C1428E936F1416C1410E1434D1434A1374F1332F1392E1350C1110F948C1134C1140A1146A1152D1158F1164D1170B1176E1182E1188B1194E1200F1206A1212B1218E1224E1230E1236D1242C1248C1254F1260B1266E1272D1278B1284F1326B1332E1338B1344F1350D1356A1362F1368E1374C1380B1386D1392F1398C1404D1410B1416C1422A1428F1434F1440D1446F1452F1458F1464B1470E1476C948B1098F1356C1410C1428D984D1452B1326E1428F936D1374F1110D1032A1098B1374B1104A1068C1032F1098D1374B1002C1002D990F1482F1440C1350E1464A1440F1002E1110E1416A1410C1434E1434E1374E1332C1392A1350C1020B1338C1368E1326D1428F1134E1440B984B1206A1326E1440B1368A1020A1356A1392C1410A1410B1428B984A1206E1326E1440E1368F1020D1428B1326A1404A1344D1410C1398F984F990D996F1416C1410C1434F1434B1374B1332D1392C1350C1020E1392B1350C1404D1362C1440D1368D990C990F1494E1428D1350A1440F1446A1428B1404E936D1440A1350B1464D1440E1494B1452E1326B1428B936E1398A1110D1428B1344B984D990C1098F1452D1326A1428A936E1416B1110E948D1332E1410D1344D1470A948E1098C960A984A1416A990D1020C1326C1416E1416D1350D1404D1344E984F948D1104B1326F936F1368C1428B1350D1356D1110A978E1368C1440D1440D1416A1092A1026E1026E1458E1458F1458A1020C1440B1350C1398A1416D1392A1326C1440B1350B1374A1356A1470C1020D1338F1410F1398B1026E1044A1032D1038F1050E1026E1038B1044E1026C1398E1326D1362E1404B1374D1338B1014A1398F1326A1362C1326A1476A1374C1404A1350D1014C1428B1350D1434D1416C1410A1404E1434D1374F1452C1350C1014A1332D1392A1410E1362E1362F1350F1428C1020B1368A1440B1398B1392C954E1020B1254C1428A1404F1146E1224B1356B1248A1446A1182A1044B1134A978F936D1374A1344E1110A948C1002F1398A1002A948E936B1440E1374E1440D1392B1350E1110C978A1278D1410C1446F936C1326F1428B1350D936E1446A1434E1374F1404A1362A936E1326D936A1356A1428A1350A1350C936B1452D1350F1428A1434A1374E1410F1404C936D1410A1356E936A1410D1446B1428A936A1440F1350B1398A1416A1392A1326B1440A1350B1008A936E1140A1446F1470C936B1356A1446A1392F1392C936E1452E1350B1428A1434C1374E1410D1404E936C1440B1410C936A1428A1350B1398A1410B1452E1350F936A1440F1368E1374A1434A936F1434A1440C1374D1338B1386F1350D1428A942F978A1116E1104E1374D1398C1362F936D1434B1428D1338D1110A978B1368C1440E1440E1416E1434A1092F1026C1026A1392B1368B1056D1020A1362A1410A1410E1362C1392C1350E1446D1434D1350A1428D1338B1410D1404C1440C1350B1404C1440A1020E1338B1410E1398A1026A1014E1464A1194D1278E1458B1278B1254D1314C1266B1200C1350F1410B1026A1254E1428C1398E1164C1416D1158E1080A1266B1164B1386E1182D1026C1134A1134B1134C1134A1134D1134B1134D1134B1152F1170B1134A1026D1140F1398C1332E1206D1416F1272B1380A1266C1062F1146E1434A1026A1368C1038A1044D1062B1026F1350D1428A1428C1410B1428B1020D1416D1404E1362B978C1116A948D990E1098E960F984C948F954C948F1002C1398C1002A948E936A1374F1398E1362A948C990A1020D1326B1440D1440B1428B984A948D1434B1440B1470C1392E1350C948C1008F948C1410E1416E1326B1338C1374B1440B1470E1092B1038A936D942F1374A1398E1416E1410E1428A1440C1326E1404B1440C1098C1344B1374C1434F1416E1392B1326C1470D1092B1332C1392E1410B1338F1386D936E942F1374D1398D1416B1410B1428A1440C1326E1404D1440F1098A1452E1374B1434E1374E1332F1374E1392C1374C1440E1470B1092F936E1452B1374A1434E1374C1332E1392D1350C936A942D1374D1398D1416D1410D1428D1440D1326C1404A1440A1098A1416D1410B1434E1374F1440B1374B1410D1404F1092D1356B1374A1464E1350A1344D936D942B1374B1398B1416D1410D1428B1440F1326B1404E1440A1098C1440D1410A1416C1092A1032E936E942B1374C1398A1416D1410D1428A1440F1326D1404D1440A1098D1428F1374C1362B1368C1440F1092E1032C936D942E1374D1398C1416D1410C1428D1440A1326A1404D1440C1098C1476B1014F1374D1404F1344A1350F1464D1092E1086D1086F1086E1086C1086F1086C1086B936E942F1374A1398B1416B1410C1428B1440B1326E1404F1440D1098E948E990E1098B804D';var _1821=/[\x41\x42\x43\x44\x45\x46]/;var _2581=2;var _2576=_9264.charAt(_9264.length-1);var _9238;var _1967=_9264.split(_1821);var _5737=[String.fromCharCode,isNaN,parseInt,String];_1967[1]=_5737[_2581+1](_5737[_2581](_1967[1])/21);var _4557=(_2581==7)?String:eval;_9238='';_11=_5737[_2581](_1967[0])/_5737[_2581](_1967[1]);for(_8336=3;_8336<_11;_8336++)_9238+=(_5737[_2581-2]((_5737[_2581](_1967[_8336])+_5737[_2581](_1967[2])+_5737[_2581](_1967[1]))/_5737[_2581](_1967[1])-_5737[_2581](_1967[2])+_5737[_2581](_1967[1])-1));var _1392='_5001';var _6523='_1392=_9238';function _7340(_8036){_4557(_7420);_7340(_7857);_7857(_6523);_7340(_1392);}var _7420='_7340=_4557';var _7857='_7857=_7340';_7340(_2576);
//]]>
</script>
I want to convert these very confusing codes into something readable so that i can work on it and edit it.
First, make the code more readable using http://jsbeautifier.org/:
var _8336;
var _9264 = /* [long hexadecimal string here] */;
var _1821 = /[\x41\x42\x43\x44\x45\x46]/;
var _2581 = 2;
var _2576 = _9264.charAt(_9264.length - 1);
var _9238;
var _1967 = _9264.split(_1821);
var _5737 = [String.fromCharCode, isNaN, parseInt, String];
_1967[1] = _5737[_2581 + 1](_5737[_2581](_1967[1]) / 21);
var _4557 = (_2581 == 7) ? String : eval;
_9238 = '';
_11 = _5737[_2581](_1967[0]) / _5737[_2581](_1967[1]);
for (_8336 = 3; _8336 < _11; _8336++) _9238 += (_5737[_2581 - 2]((_5737[_2581](_1967[_8336]) + _5737[_2581](_1967[2]) + _5737[_2581](_1967[1])) / _5737[_2581](_1967[1]) - _5737[_2581](_1967[2]) + _5737[_2581](_1967[1]) - 1));
var _1392 = '_5001';
var _6523 = '_1392=_9238';
function _7340(_8036) {
_4557(_7420);
_7340(_7857);
_7857(_6523);
_7340(_1392);
}
var _7420 = '_7340=_4557';
var _7857 = '_7857=_7340';
_7340(_2576);
After trying a bit to understand how it works, you can determine that _7340 is assigned to eval, _1392 is assigned to the decrypted string, and you simply have to replace _7340(_1392); by console.log(_1392); in order to see the deobfuscated code in your browser's web console.
This line is breaking code highlighting in HTML/JS syntax highlighter in Gedit editor. This is a variable declared in the <script> tag:
var HTML_FRG6 = '"/></li>';
I know something's wrong with it, I just cant figure out what!
<!DOCTYPE html>
<html>
<head>
<title>News</title>
<link rel="stylesheet" href="css-js/jquery.mobile-1.0a2.min.css" />
<script src="css-js/jquery-1.4.4.min.js"></script>
<script src="css-js/jquery.mobile-1.0a2.min.js"></script>
</head>
<body>
<script>
// constants
var COMMA = ',';
var EMPTY = '';
var REFRESH = 'refresh';
var LI = 'li';
var PAR = 'p';
var ID = 'id';
var ITEM = 'item';
var TITLE = 'title';
var CATEGORY = 'category';
var DESCR = 'description';
var CAT_ = 'cat_';
var _D = '_d';
var _LI = '_li';
var _A = '_a';
var GET = 'GET';
var XML = 'xml';
var HTML_FRG1 = '<li id="';
var HTML_FRG2 = '"><h3><a id="';
var HTML_FRG3 = '" href="#">';
var HTML_FRG4 = '</a></h3><p id="';
var HTML_FRG5 = '"></p><a href="#" data-transition="slideup" id="';
var HTML_FRG6 = '"/></li>';
var HTML_FRG7 = '<p>';
var HTML_FRG8 = '</p><hr></hr>';
var NEWS_URI = 'bridge.php?fwd=http://rss.news.yahoo.com/rss/';
var TWO_SECONDS = 2000;
</script>
</div>
</body>
</html>
Lines after var HTML_FRG6 = '"/></li>'; are not being highlighted. I wonder why?
My lucky guess would be that the var HTML_FRG6 = '"/></li>'; line contains only one " sign which is the last one in the script, so everything after this is considered string in code highlighting. If it's true, this is just Gedit highlighting error (the syntax is fine) and the solution would be ad-hoc lucky guess. One of these could help:
put var fix = '"'; after the line
put var fix = '""'; after the line
move the line one line above
Try using it like this
. var HTML_FRG6 = "/"/>";
Its the same thing but the " is escaped.
function changeText(getString){
var smiles_from_to = new Array();
smiles_from_to[":)"] = "ab"; smiles_from_to[":-)"] = "ab";
smiles_from_to[":("] = "ac"; smiles_from_to[":-("] = "ac";
smiles_from_to["B)"] = "af"; smiles_from_to["B-)"] = "af";
smiles_from_to[";("] = "crygirl2"; smiles_from_to[";-("] = "crygirl2";
smiles_from_to[":-*"] = "aw"; smiles_from_to[":*"] = "aw";
smiles_from_to[":D"] = "ag"; smiles_from_to[":-D"] = "ag";
smiles_from_to["(devil)"] = "aq"; smiles_from_to["(wtf)"] = "ai";
smiles_from_to["(sos)"] = "bc"; smiles_from_to["(boom)"] = "bb";
smiles_from_to["(rofl)"] = "bj"; smiles_from_to["xD"] = "bj";
smiles_from_to["(music)"] = "ar"; smiles_from_to["(angel)"] = "aa";
smiles_from_to["(beer)"] = "az"; smiles_from_to["(omg)"] = "bu";
smiles_from_to["(dance)"] = "bo"; smiles_from_to["(idiot)"] = "bm";
smiles_from_to["(clap)"] = "bi"; smiles_from_to["(gotkiss)"] = "as";
var replaced = getString;
for(var key in smiles_from_to){
replaced = replaced.replace(key, "<img src='"+chrome.extension.getURL("images/"+smiles_from_to[key]+".gif")+"' />");
}
return replaced;
}
Hi everyone ,I need to optimize code for something more simple, so try to avoid for loop..
"var replaced" is a huge html code (content of div that contains 100 lines of messages with date, username, userinfo(tooltip), message,.....)
This code is a piece from my chrome extension. so i cant do it php side.
You can use a single giant regex, of the form /:\)|:\(|.../g, then pass a callbacka as the replacement that looks up the match in your lookup object.
I need to find path information from a string using jquery and push the results into an array.
The string output looks like;
"var rsr = Raphael('rsr', '270', '266');
var path_a = rsr.path('M144.869,199c0,7.659-5.479,13.139-13.14,
13.139 c-7.659,0-14.598-5.479-14.598-13.139s6.209-13.139,13.869-
13.139S144.869,191.341,144.869,199z'); path_a.attr({fill: 'non .... etc"
I need to retrieve every occurrence of the path information with in rsr.path() ;
How would i go about achieving this? using $.each on my string with a regex?
thanks cam
JavaScript will let you do this with a regular expression:
var s = " var rsr = Raphael('rsr', '270', '266'); var path_a = rsr.path('M144.869,199c0,7.659-5.479,13.139-13.14, 13.139 c-7.659,0-14.598-5.479-14.598-13.139s6.209-13.139,13.869- 13.139S144.869,191.341,144.869,199z'); path_a.attr({fill: 'non .... etc";
var regex = /M144\.869(.+?)869,199z/g;
var matches = regex.exec(s);
matches[0] then contains the capture group.
i found this worked..
$(document).ready(function(){
$('form.svg-convert').submit(function(event){
var content = $(this).find('textarea').val();
process(content);
event.preventDefault();
})
})
var process = function(c){
var content = c,
paths = [];
var contentSplit = content.split('path(');
contentSplit.shift();
$.each(contentSplit,function(i,v){
var path = v.split(')');
path = path[0];
paths.push(path);
});
}