I need to scrape data from a website after the data is loaded,
There is a process that running in a loop between 1 to 200, I need to get the result after the process arrived to 200 on the HTML itself.
1. Is it possible? I know to work with cheerio but I didn't find the way to handle how to catch it live after the process ended.
2. How can I ignore CORS provision when I try to request using axios http get request.
I didn't understand how to use proxy in vue.config.js. I didn't find the full explanation for how to use it.
Here is my code, of course I changed some data for my safety:
<div class="hello">
<h1>{{ msg }}</h1>
<ul>
<li v-for="(message, index) in messages" :key="index">
<b>{{ messages.ip }} [{{ message.type }}]:</b>
{{ message.blocked }}
</li>
</ul>
</div>
</template>
<script>
import axios from "axios";
import cheerio from "cheerio";
export default {
name: "ScrapIP",
props: {
msg: String,
messages: Array
},
methods: {
fetchUrl() {
for (let i = 0; i < 5; i++) {
const ip = "192.168.0." + i;
const url = "http://xxx/yyy.org/lookup/" + ip + ".html";
axios.get(url).then(response => {
const $ = cheerio.load(response.data);
setTimeout(() => {
if ($(".global_data_cnt_DNSBLBlacklistTest").text() == 243) {
this.messages.push({
ip: ip,
type: "Blacklist Test",
blocked: $(".global_data_cnt_DNSBLBlacklistTest").text()
});
}
}, 10000);
});
}
}
},
created() {
this.fetchUrl();
}
};
</script>