Questionnaire Scrapper

This is a custom website scrapper for a task that I am currently undertaking at
work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
if (JSON.parse(localStorage.getItem('questions')) === null) {
// Find all yes radio buttons and auto click
$("label:contains('Yes')").click();
$("label:contains('No action points identified')").click();
$('textarea').last().append('N/A');

setTimeout(function() {
var section = $('.breadcrumb-title').html();

var q = [{
'Company': $('.standard-breadcrumbs li:nth-child(5) span').html(),
'Sections': []
}];


q[0]['Sections'].push({
'section': $('.breadcrumb-title').html(),
questions: []
});

$('.questionnaire-answers-section-question-options').each(function(ele) {
q[0]['Sections'][0]['questions'].push({
'Question': $(this).find('p').html(),
'Answer': $(this).find('.question-answer-selected-text span:nth-child(2)').html(),
'Resons': $(this).find('.question-answer-textanswered').html()
})
})

localStorage.setItem('questions', JSON.stringify(q));
$('.standard-submit').click();
}, 200);

} else {
// Find all yes radio buttons and auto click
$("label:contains('Yes')").click();
$("label:contains('No action points identified')").click();
$('textarea').last().append('N/A');

setTimeout(function() {
var q = JSON.parse(localStorage.getItem('questions'));

var nq = {
'section': $('.breadcrumb-title').html(),
'questions': []
};

$('.questionnaire-answers-section-question-options').each(function(ele) {

nq['questions'].push({
'Question': $(this).find('p').html(),
'Answer': $(this).find('.question-answer-selected-text span:nth-child(2)').html(),
'Resons': $(this).find('.question-answer-textanswered').html()
})
})

q[0]['Sections'].push(nq);
localStorage.setItem('questions', JSON.stringify(q));

$('.standard-submit').click();
}, 200)
}
1
2
copy(JSON.parse(localStorage.getItem('questions')));
localStorage.clear();