Posts

Showing posts with the label find

Replace character string between new lines

Image
Clash Royale CLAN TAG #URR8PPP Replace character string between new lines I am trying to edit a file such that strings flanked by new lines are removed. My file looks like: ENSG00000000460_chr1.dat varX data data data data data varX data data data data data varX data data data data data ENSG00000005801_chr11.dat ENSG00000006007_chr16.dat ENSG00000006607_chr2.dat varX data data data data data varX data data data data data ENSG00000010219_chr12.dat ENSG00000011052_chr17.dat The output I am trying to get would delete lines which are flanked by new lines (and delete the new lines) resulting in output which looks like: ENSG00000000460_chr1.dat varX data data data data data varX data data data data data varX data data data data data ENSG00000006607_chr2.dat varX data data data data data varX data data data data data I have tried various ideas in sed, but it either returns: sed 's/[na-zA-Z0-9n]//g' file.txt | head _. . .- . . . . . . .-...

Use Rename collection in mongoose

Image
Clash Royale CLAN TAG #URR8PPP Use Rename collection in mongoose I have a problem. I renamed my collection responses into old. It works really well but now I need to retrieve my data and my impediment is that I only used the model to retrieve my data from a collection. But now I need to retrieve my data from my renamed collection but I have no model and schema. I tried to create a schema and a model but it didn't work. It returns no elements. Here is a part of the code : app.get("/Play", function (req, res) { var urlTempBox = 'http://localhost:3000/Play'; /////////////////////////////////////////////////////////// request(urlTempBox,function(error, response, body) { if (error) { throw(error); } else{ var jobj = JSON.parse(response.body); persistRS(jobj); setTimeout(function() { ResponseDatabase.find() .populate('unitCode') .exec(function(err, finalData){ ...

Can't figure out Beautifulsoup find() command for this HTML

Image
Clash Royale CLAN TAG #URR8PPP Can't figure out Beautifulsoup find() command for this HTML I am trying to scrape some info from a page with python and Beautiful soup and i cant seem to write the right path to what i need, the html is: <div class="operator active" data-operator_name="Etisalat" data- operator_id="5"><div class="operator_name_etisalat"></div></div> And i am trying to get that operator name "Etisalat", i got this far: def list_contries(): select = Select(driver.find_element_by_id('international_country')) select.select_by_visible_text('France') request = requests.get("https://mobilerecharge.com/buy/mobile_recharge?country=Afghanistan&operator=Etisalat") content = request.content soup = BeautifulSoup(content, "html.parser") # print(soup.prettify()) prov=soup.find("div", {"class": "operator active"})['data-operator_name']...