-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscraping_computrabajo.php
77 lines (40 loc) · 1.57 KB
/
scraping_computrabajo.php
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
//codigo para trabajar html
require_once('simple_html_dom.php');
//url to scrap
$url = 'https://www.computrabajo.com.mx/trabajo-de-programador-en-morelia';
$curl = curl_init();
//headers
$config['useragent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127';
curl_setopt($curl, CURLOPT_USERAGENT, $config['useragent']);
curl_setopt($curl, CURLOPT_REFERER, $url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($curl);
curl_close($curl);
$domResult = new simple_html_dom();
$domResult -> load($result);
//Titulos de trabajo
foreach($domResult -> find('h1.fs18.fwB') as $a){
$job_title_ct[] = $a -> plaintext;
}
//Empresa que realizo la oferta
foreach($domResult -> find('a.fc_base.hover.it-blank') as $b){
$companyName_ct[] = $b -> plaintext;
}
//info_extra
foreach($domResult -> find('p.fc_aux.t_word_wrap.mb10.hide_m') as $d){
$job_snippet_ct[] = $d -> plaintext;
}
//dias de publicacion
foreach($domResult -> find('p.fs13.fc_aux') as $e){
$date_ct[] = $e -> plaintext;
}
$a = array ('Title' ,'Company', 'info', 'Date');
$b = $job_title_ct;
$c = $companyName_ct;
$d = $job_snippet_ct;
$e = $date_ct;
$ct = array_combine($a, array($b,$c,$d,$e));
?>