'I parsed the site using the Scrapy library in python and I can`t filter the response code
I'm new in python and couldn't find any information about my problem. I parsed the site using the Scrapy library and then got a code like this:
var pickupMap = {};
var arBounds = {'112176':{'MIN':['51.534052','43.157633'],'MAX':['51.542724','43.203497']},'106812':{'MIN':['44.733254','33.845615'],'MAX':['44.75256','33.851458']},'58584':{'MIN':['50.575816','36.6502877'],'MAX':['50.5923938','36.667544']},'106799':{'MIN':['45.048373','34.597092'],'MAX':['45.062299','34.601114']},'66656':{'MIN':['59.413621','56.769687'],'MAX':['59.424759','56.816496']},'66674':{'MIN':['52.504677','85.144291'],'MAX':['52.54653','85.203761']},'267176':{'MIN':['48.782604','132.920081'],'MAX':['48.798244','132.939032']},'267212':{'MIN':['52.114018','23.669482'],'MAX':['52.126701','23.774195']},'66653':{'MIN':['56.880181','59.774094'],'MAX':['56.948651','60.01527']},'108135':{'MIN':['56.9659485','60.535173'],'MAX':['56.980787','63.2612845']},'106805':{'MIN':['47.527158','42.195092'],'MAX':['47.531131','42.233503']},'274097':{'MIN':['48.759037','44.771609'],'MAX':['48.79625','44.807619']},'66657':{'MIN':['60.694565','28.754'],'MAX':['60.707573','28.793622']},'58577':{'MIN':['57.576273','34.556255'],'MAX':['57.599057','34.565792']},'66655':{'MIN':['56.329635','37.526226'],'MAX':['56.369589','37.5746']},'106814':{'MIN':['45.198286','33.347581'],'MAX':['45.211952','33.354979']},'112174':{'MIN':['55.137207','59.665829'],'MAX':['55.173553','59.67374']},'58585':{'MIN':['56.985011','40.946888'],'MAX':['57.003985','41.009084']},'69383':{'MIN':['57.6628086','63.054499'],'MAX':['57.683928','63.0896845']},'':{'MIN':['51.191449','-0.001'],'MAX':['54.91634971','71463811.001']},'58572':{'MIN':['56.101544','69.423629'],'MAX':['56.135054','69.522743']},'66699':{'MIN':['54.730576','20.439212'],'MAX':['54.765194','20.56685']},'269484':{'MIN':['56.378167','61.932036'],'MAX':['56.413885','61.947573']},'69385':{'MIN':['53.789821','81.32014'],'MAX':['53.79303','81.354489']},'264806':{'MIN':['49.791049','73.099218'],'MAX':['49.82414','73.13433']},'106807':{'MIN':['45.299679','36.42221'],'MAX':['45.367979','36.509611']},'58588':{'MIN':['52.74497','32.236859'],'MAX':['52.760139','32.260894']},'102547':{'MIN':['55.11894','61.608049'],'MAX':['55.124538','61.640341']},'264974':{'MIN':['54.886978','61.343028'],'MAX':['54.904376','61.39714']},'66670':{'MIN':['56.601861','57.766682'],'MAX':['56.615693','57.807467']},'261955':{'MIN':['44.910851','37.985151'],'MAX':['44.947745','37.993287']},'58573':{'MIN':['56.14182','44.181597'],'MAX':['56.155776','44.204131']},'69417':{'MIN':['53.10206','46.543679'],'MAX':['53.123156','46.59776']},'66647':{'MIN':['55.424384','65.277092'],'MAX':['55.461665','65.372571']},'253903':{'MIN':['54.661021','86.167953'],'MAX':['54.682925','86.188486']},'170833':{'MIN':['52.618193','39.543683'],'MAX':['52.635198','39.665995']},'66648':{'MIN':['53.35057','58.936765'],'MAX':['53.447636','59.065544']},'275128':{'MIN':['40.427814','71.701713'],'MAX':['40.442153','71.728558']},'101457':{'MIN':['55.031217','60.114735'],'MAX':['55.1002966','60.1401356']},'225884':{'MIN':['53.8771353','30.362485'],'MAX':['53.945279','30.392657139']},'66661':{'MIN':['55.563608','41.997268'],'MAX':['55.587486','42.061936']},'66692':{'MIN':['55.368178','36.741326'],'MAX':['55.393465','36.766862']},'66675':{'MIN':['57.905372','59.932745'],'MAX':['57.927342','60.132348']},'66707':{'MIN':['55.753122','60.702335'],'MAX':['55.766314','60.716441']},'58586':{'MIN':['51.771529','55.0732827'],'MAX':['51.846521','55.198791']},'125994':{'MIN':['50.448833','40.14024'],'MAX':['53.31811','82.97458']},'106817':{'MIN':['45.438917','34.731514'],'MAX':['45.452296','34.750506']},'267215':{'MIN':['44.999903','38.926578'],'MAX':['45.00201','38.93406']},'58633':{'MIN':['53.209776','44.921834'],'MAX':['53.23547','45.064627']},'58615':{'MIN':['57.959669','55.928649'],'MAX':['58.102621','56.359388']},'66678':{'MIN':['58.03171','38.81444'],'MAX':['58.035264','38.892135']},'106806':{'MIN':['44.573511','33.437484'],'MAX':['44.62984','33.530163']},'66687':{'MIN':['64.540527','39.802964'],'MAX':['64.551171','39.832237']},'66673':{'MIN':['59.610436','60.577655'],'MAX':['59.613716','60.597765']},'106809':{'MIN':['44.91449','34.045459'],'MAX':['45.028682','34.156152']},'66700':{'MIN':['54.7672986','32.009223'],'MAX':['54.820036','32.049045']},'101869':{'MIN':['59.647538','56.692707'],'MAX':['59.704429','56.77617']},'106795':{'MIN':['43.4160732','39.7478507'],'MAX':['43.6347401','39.9517945']},'58592':{'MIN':['51.281895','37.788627'],'MAX':['51.329463','37.8778']},'66652':{'MIN':['56.893262','62.0229961'],'MAX':['56.8970501','62.052443']},'274263':{'MIN':['42.899291','71.334358'],'MAX':['42.930338','71.347661']},'58578':{'MIN':['58.218534','68.267755'],'MAX':['58.237297','68.335208']},'112171':{'MIN':['54.040707','61.508742'],'MAX':['54.085352','61.638697']},'58568':{'MIN':['57.110806','65.469278'],'MAX':['57.195362','65.63699']},'270647':{'MIN':['51.796016','107.602286'],'MAX':['51.84089','107.65223']},'234489':{'MIN':['45.219844','39.63721'],'MAX':['45.22275','39.71948']},'58567':{'MIN':['55.066308','61.279571'],'MAX':['55.269082','61.478051']},'66671':{'MIN':['56.080507','63.630436'],'MAX':['56.084287','63.663642']},'262107':{'MIN':['51.729026','75.295823'],'MAX':['51.748582','75.319621']}};
var storePlacemarks = {};
var pickupMapCollection = {};
var cityCenter = [39.767945, 64.421701];
var cityZoom = 10;
var cityIcon = '/local/templates/main/images/icons/placemark.svg';
//var countryCenter = [55.7123675178337, 101.99916095676001];
//var countryZoom = 2.5;
var countryCenter = [59.857900590951736, 50.062125866402454];
var countryZoom = 4;
var countryIcon = '/local/templates/main/images/icons/miniIcon.png';
var shop_list = $('#shop_list .store');
var cityID = 274859;
var h1 = $('.content h1.h1');
ymaps.ready(function(){
pickupMap = new ymaps.Map("map", {
flying: true,
center: cityCenter,
zoom: cityZoom,
controls: ['zoomControl']
});
pickupMapCollection = new ymaps.GeoObjectCollection();
storePlacemarks[2061] = new ymaps.Placemark([44.862148, 38.166802], new ymaps.data.Manager({
store_id: 2061,
clusterCaption: 'Brand1',
balloonContentBody: 'Somethin1'
}), {
iconLayout: 'default#image',
iconImageHref: '/local/templates/main/images/icons/placemark.svg',
iconImageSize: [48, 58],
iconImageOffset: [-24, -58]
});
pickupMapCollection.add(storePlacemarks[2061]);
storePlacemarks[2260] = new ymaps.Placemark([47.089910355788, 39.436331546436], new ymaps.data.Manager({
store_id: 2260,
clusterCaption: 'Brand2',
balloonContentBody: 'Something2'
}), {
iconLayout: 'default#image',
iconImageHref: '/local/templates/main/images/icons/placemark.svg',
iconImageSize: [48, 58],
iconImageOffset: [-24, -58]
});
pickupMapCollection.add(storePlacemarks[2260]);
storePlacemarks[2124] = new ymaps.Placemark([51.166561, 53.029105], new ymaps.data.Manager({
store_id: 2124,
clusterCaption: 'Brand3',
balloonContentBody: 'Something3'
}), {
iconLayout: 'default#image',
iconImageHref: '/local/templates/main/images/icons/placemark.svg',
iconImageSize: [48, 58],
iconImageOffset: [-24, -58]
});
pickupMapCollection.add(storePlacemarks[2124]);
My task is that, I have to cut out part of this code (js code), like this:
[
{
store_id: 2061,
clusterCaption: 'Brand1',
balloonContentBody: 'Somethin1'
},
{
store_id: 2260,
clusterCaption: 'Brand2',
balloonContentBody: 'Somethin2'
},
{
store_id: 2124,
clusterCaption: 'Brand3',
balloonContentBody: 'Somethin3'
},
]
You need to use regex because there is a lot of data.
My regex code:
r"(?<=ymaps\.data\.Manager\()(.*?)(?=\)\,*)"
P.s. Thanks for your help in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
