Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how i create json file #1581

Closed
javedabbas112 opened this issue Apr 24, 2019 · 10 comments
Closed

how i create json file #1581

javedabbas112 opened this issue Apr 24, 2019 · 10 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation state: needs more info the author of the issue needs to provide more details

Comments

@javedabbas112
Copy link

console.log("Anycodes Scraper Loaded!");

var titles = document.querySelectorAll(".bf1808");

var titles_count = titles.length;

for (var index = 0; index < titles_count; index++) {
console.log(titles[index].textContent);
}

var coupons = document.querySelectorAll(".offer_list_item");

var coupons_count = coupons.length;

for (var index = 0; index < coupons_count; index++) {
var title = coupons[index].querySelector(".bf1808").textContent;
var type = coupons[index].querySelector(".cou_property").textContent.trim();
if(type=="Code"){
console.log("Coupon");
var coupon_id = document.querySelectorAll(".offer_list_item")[index].getAttribute("data-cid");
console.log("https://www.anycodes.com/coupon-detail-"+coupon_id+".html");
var url = "https://www.anycodes.com/coupon-detail-"+coupon_id+".html"

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
   
    document.querySelector("body").innerHTML = this.response;
  
    var coupon_code = document.querySelector("#copy-code").textContent;
    console.log(coupon_code);
    myObj={
      


    } 
  
  }
};

xhttp.open("GET", url, true);

xhttp.send();

}else{
console.log("Deal");
}
// console.log(title + " : " + type);
}

@nlohmann
Copy link
Owner

The code in your example is JavaScript. This library is for C++. Are you sure you have opened this issue in the correct GitHub repository?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Apr 24, 2019
@javedabbas112
Copy link
Author

yes its javascript webscraping extention

@nlohmann
Copy link
Owner

How is the question related to JSON for Modern C++?

@javedabbas112
Copy link
Author

how can i create javascript object

@nlohmann
Copy link
Owner

In order to asses your issue, we need the following information:

  • What is the issue you have?

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

  • What is the expected behavior?

  • And what is the actual behavior instead?

  • Which compiler and operating system are you using? Is it a supported compiler?

  • Did you use a released version of the library or the version from the develop branch?

  • If you experience a compilation error: can you compile and run the unit tests?

@javedabbas112
Copy link
Author

my issue is that i cant create json file

@nlohmann
Copy link
Owner

Please add the details above.

@huuson235
Copy link

I think I understand what he means. I also want to save my json object to a json file for other programs to read. How can I save json object to file?

@nickaein
Copy link
Contributor

@huuson235: As described in Serialization section, call dump() on your JSON object to get its string representation. That string can be then written to a JSON file.

More info on dump() can be found at its documentation page.

@nlohmann
Copy link
Owner

@javedabbas112 Do you need further information?

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label May 24, 2019
@nlohmann nlohmann closed this as completed Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

4 participants