2017-07-23 19:56:51 +02:00
|
|
|
{% extends "main.html" %}
|
2017-09-07 13:40:42 +02:00
|
|
|
{% block title %}Scrape{% endblock %}
|
2017-07-23 19:56:51 +02:00
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
<div class="container">
|
2017-09-07 13:40:42 +02:00
|
|
|
<h1>Scrape a page</h1>
|
2017-07-23 19:56:51 +02:00
|
|
|
|
2017-09-07 16:22:16 +02:00
|
|
|
<form class="form-inline" role="form" action="scrape" method=post>
|
2017-07-23 19:56:51 +02:00
|
|
|
<div class="form-group">
|
2017-10-10 11:16:16 +02:00
|
|
|
<label for="url">URL to scrape:</label>
|
|
|
|
<input type="text" class="form-control" name="url" id=url placeholder="URL to scrape">
|
|
|
|
<label for="depth">Depth:</label>
|
|
|
|
<select class="form-control" name="depth" id=depth>
|
|
|
|
<option value="1">1</option>
|
|
|
|
<option value="2">2</option>
|
|
|
|
<option value="3">3</option>
|
|
|
|
<option value="4">4</option>
|
|
|
|
<option value="5">5</option>
|
|
|
|
<option value="6">6</option>
|
|
|
|
<option value="7">7</option>
|
|
|
|
<option value="8">8</option>
|
|
|
|
<option value="9">9</option>
|
|
|
|
</select>
|
2019-02-17 18:43:25 +01:00
|
|
|
<label for="listing">Public</label>
|
2019-02-18 14:29:15 +01:00
|
|
|
<input type="checkbox" name="listing" checked="true"></input>
|
2017-07-23 19:56:51 +02:00
|
|
|
</div>
|
2019-03-29 20:11:44 +01:00
|
|
|
<label for="os">Choose an operating system</label>
|
|
|
|
<select class="form-control" name="os" id="os">
|
|
|
|
{% for os in user_agents.keys() %}
|
|
|
|
<option value="{{ os }}">{{ os }}</option>
|
|
|
|
{% endfor%}
|
|
|
|
</select>
|
|
|
|
{% for os, browsers in user_agents.items() %}
|
|
|
|
<div id="{{os.replace(' ', '_')}}" class="style-sub-1" {% if loop.index0 != 0 %}style="display: none;"{%endif%}>
|
|
|
|
<select class="form-control" name="browser">
|
|
|
|
{% for browser in browsers.keys()%}
|
|
|
|
<option value="{{ browser }}">{{ browser }}</option>
|
|
|
|
{% endfor%}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
{% set outer_loop = loop %}
|
|
|
|
{% for browser, user_agents in browsers.items()%}
|
|
|
|
<div id="{{os.replace(' ', '_')}}_{{browser.replace(' ', '_')}}" class="style-sub-2" {% if not loop.first or not outer_loop.first %} style="display: none;"{%endif%}>
|
|
|
|
<select class="form-control" name="user_agent">
|
|
|
|
{% for user_agent in user_agents %}
|
2019-04-02 23:05:31 +02:00
|
|
|
<option value="{{ user_agent }}" >{{ user_agent }}</option>
|
2019-03-29 20:11:44 +01:00
|
|
|
{% endfor%}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
{% endfor%}
|
|
|
|
{% endfor%}
|
2017-09-07 16:22:16 +02:00
|
|
|
<button type="submit" class="btn btn-default">Scrape</button>
|
2017-07-23 19:56:51 +02:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|
2019-03-29 20:11:44 +01:00
|
|
|
|
|
|
|
{% block scripts %}
|
|
|
|
{{ super() }}
|
|
|
|
<script>
|
|
|
|
$("#os").change(function(){
|
|
|
|
var os_name = $(this).find(":selected").val().replace(/(:|\.|\[|\]|,|=)/g, "\\$1").replace(/ /g,"_");
|
|
|
|
var first_browser_name = $("[id='" + os_name + "']").find('select option:first-child').val().replace(/(:|\.|\[|\]|,|=)/g, "\\$1").replace(/ /g,"_");
|
2019-04-02 23:05:31 +02:00
|
|
|
// Hide and disable everything
|
2019-03-29 20:11:44 +01:00
|
|
|
$(".style-sub-1").hide();
|
2019-04-02 23:05:31 +02:00
|
|
|
$(".style-sub-1 > select").attr('disabled', true);
|
2019-03-29 20:11:44 +01:00
|
|
|
$(".style-sub-2").hide();
|
2019-04-02 23:05:31 +02:00
|
|
|
$(".style-sub-2 > select").attr('disabled', true);
|
|
|
|
|
2019-03-29 20:11:44 +01:00
|
|
|
$("[id='" + os_name + "']").show();
|
2019-04-02 23:05:31 +02:00
|
|
|
$("[id='" + os_name + "'] > select").removeAttr('disabled');
|
2019-03-29 20:11:44 +01:00
|
|
|
$("[id='" + os_name + '_' + first_browser_name + "']").show();
|
2019-04-02 23:05:31 +02:00
|
|
|
$("[id='" + os_name + '_' + first_browser_name + "'] > select").removeAttr('disabled');
|
2019-03-29 20:11:44 +01:00
|
|
|
});
|
|
|
|
$('select[name="browser"]').change(function(){
|
|
|
|
var browser_name = $(this).find(":selected").val().replace(/(:|\.|\[|\]|,|=)/g, "\\$1").replace(/ /g,"_");
|
|
|
|
var os_name = $(this).parent().attr("id").replace(/(:|\.|\[|\]|,|=)/g, "\\$1").replace(/ /g,"_");
|
2019-04-02 23:05:31 +02:00
|
|
|
|
|
|
|
// Hide what makes sense
|
2019-03-29 20:11:44 +01:00
|
|
|
$(".style-sub-2").hide();
|
2019-04-02 23:05:31 +02:00
|
|
|
$(".style-sub-2 > select").attr('disabled', true);
|
|
|
|
|
2019-03-29 20:11:44 +01:00
|
|
|
$("[id='" + os_name + '_' + browser_name + "']").show();
|
2019-04-02 23:05:31 +02:00
|
|
|
$("[id='" + os_name + '_' + browser_name + "'] > select").removeAttr('disabled');
|
2019-03-29 20:11:44 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|