-
Notifications
You must be signed in to change notification settings - Fork 0
/
xingzuo.php
executable file
·285 lines (210 loc) · 6.81 KB
/
xingzuo.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<?php
// phpinfo();die;
header("Content-type: text/html; charset=utf-8");
/***
* 采集xxhh.com
*
* */
// set_time_limit(0);
include './simple_html_dom.php';
include './config.php';
// 新建一个Dom实例
$html = new simple_html_dom();
// $sourceList = 'http://weixin.sogou.com/pcindex/pc/pc_'.$type.'/';
// $contentUrl = "http://weixin.sogou.com/gzh?openid=oIWsFt9eVugAjPSViucxPUMqZRTc&ext=lA5I5al3X8BYrtW1H7KizeSlxz3j7jXNbhYq5hHUiK3kRa_38c2fM0YicIPGGskc";
//$snoopy->fetchlinks($contentUrl);
// $snoopy->fetchtext($sourceURL);
//$snoopy->fetch($contentUrl);
//$return = $snoopy->results;
// ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)');
ini_set('user_agent','Sosospider+(+http://help.soso.com/webspider.htm)');
$dA = array(
'chunv'=>'xingzuo-chunv.txt',
'mojie'=>'xingzuo-mojie.txt',
'sheshou'=>'xingzuo-sheshou.txt',
'shizi'=>'xingzuo-shizi.txt',
'shuangyu'=>'xingzuo-shuangyu.txt',
'shuangzi'=>'xingzuo-shuangzi.txt',
'shuiping'=>'xingzuo-shuiping.txt',
'juxie'=>'xingzuo-juxie.txt',
'tianxie'=>'xingzuo-tianxie.txt',
'tiancheng'=>'xingzuo-tiancheng.txt',
);
$table = 'xingzuo';
// $i = 0;
foreach ($dA as $key2 => $value2) {
# code...
//key2 为标识
$urlA = file('./'.$value2);
foreach ($urlA as $key => $value) {
# code...
$url_t = explode('^^',$value);
echo $url_t[0];
$html =file_get_html('http://www.xzw.com/'.$url_t[0]);
foreach($html->find('.sbody') as $element) {
// echo $str = strip_tags($element->innertext)."\n";
//制定需要操作的数据数组
echo $data['title'] = $url_t[1];
$data['content'] = trim(strip_tags($element->innertext));
$data['cate'] = $key2;
$data['href'] = $url_t[0];
//执行添加操作 返回1 插入成功
$r = $db->insert($table,$data);
echo $r."\n";
// ?
// echo $key2;
// $s = $element->find('.bar',0)->title."\n";
// $s = floatval($s)."\n";
// if($s<= 4.5 && $s>0){
// $str .= strip_tags($element->find('td',2)).':'.strip_tags($element->find('td',3)) . "\n";
// }
}
// die;
}
}
print_r();die;
// print_r($context);die;
// print_r($html);die;
// //var_dump($html);
// $logo = $html->find('div.img-box img',0);
// $wxName = $html->find('h3',0)->innertext;
// $wxID = $html->find('label[name=em_weixinhao]',0)->innertext;
// $sp = $html->find('span.sp-txt',0)->innertext;
// $auto = $html->find('span.sp-txt',1)->innertext;
// $qr_img = $html->find('div.v-box img',0);
// echo "logo:".$logo->src;
// echo "<br />";
// echo "wxname:".($wxName);
// echo "<br />";
// echo "wxID:".$wxID;
// echo "<br />";
// echo "descript:".$sp;
// echo "<br />";
// echo "auto:".$auto;
// echo "<br />";
// echo "qr_path:".$qr_img->src;
// echo "<br />";
//文章信息
for($i=1;$i<100;$i++){
// $i = 0;
$contentUrl = "http://www.xzw.com/astro/scorpio/l_".$i.".html";
//获取所有的img元素
$html =file_get_html($contentUrl);
foreach($html->find('.l-item li h3') as $element) {
$str .= ($element->find('a',0)->href).'^^'.strip_tags($element->innertext)."\n";
// $s = $element->find('.bar',0)->title."\n";
// $s = floatval($s)."\n";
// if($s<= 4.5 && $s>0){
// $str .= strip_tags($element->find('td',2)).':'.strip_tags($element->find('td',3)) . "\n";
// }
}
echo $str;
}
// echo strlen($str);
if(strlen($str)>5000){
file_put_contents('./xingzuo-tianxie.txt', trim($str));
} else {
file_put_contents('/home/wwwroot/proxy-over.dat', 'die'.date('Y-m-d H:i:s')."\n");
}
// foreach($html->find('.txt-box h3') as $element)
// $arr['name'][] = strip_tags($element->innertext) . "\n";
// foreach($html->find('.txt-box h4 span') as $element)
// $arr['weixinhao'][] = strip_tags($element->innertext) . "\n";
// foreach($html->find('.txt-box .s-p3') as $element)
// $arr['desc'][] = strip_tags($element->innertext) . "\n";
// // foreach($html->find('.txt-box .s-p3',1) as $element)
// // $arr['sign'][] = strip_tags($element->innertext) . "\n";
// // foreach($html->find('.txt-box .s-p3',2) as $element)
// // $arr['article'][] = strip_tags($element->innertext) . "\n";
// foreach($html->find('.txt-box a') as $element)
// $arr['link'][] = strip_tags($element->href) . "\n";
// $i = 0;
// foreach ($arr['desc'] as $key => $value) {
// # code...
// $arr['desc2'][$i][] = $value;
// if($key%3==2){
// $i++;
// }
// }
// unset($arr['desc']);
print_r($arr);
// 获取所有的a链接
// foreach($html->find('._item') as $element)
// echo $element->href . "\n";
die;
// $titleObj = $html->find('._item');
// print_r($titleObj);die;
//var_dump($titleObj);
$title = $titleObj->innertext;
$link = $titleObj->href;
$head_pic = $html->find('div.img_box2',0);
echo $title;
echo "<br />";
echo $link;
echo "<br />";
echo $head_pic->src;
echo "<br />";
echo "<br />";
echo "<br />";
echo "<br />";
// print_r($return);
exit();
for($i=2;$i<15;$i++){
$return = array();
$sourceList1 = $sourceList.$i.'.html';
// echo "<br>";
// $snoopy->fetchlinks($sourceList1);
// $return = $snoopy->results;
$html = file_get_html($sourceList1);
$return = $html->find('a');
foreach ($return as $key => $value) {
if(checkUrl($value->href)){
//echo $value."<br />";
$wxIdArr[] = $value;
saveInfoWx($value->href,$type);
}else{
//echo $i.":false url:".$value."<br />";
}
}
sleep(3);
}
function saveInfoWx($url,$type){
echo $url."<br />";
$html = file_get_html($url);
$logo = $html->find('div.img-box img',0);
$wxName = $html->find('h3',0)->innertext;
$wxID = $html->find('label[name=em_weixinhao]',0)->innertext;
$sp = $html->find('span.sp-txt',0)->innertext;
$auto = $html->find('span.sp-txt',0)->innertext;
$qr_img = $html->find('div.v-box img',0);
//先保存到本地文件
//顺序微信id,微信昵称,logo,描述,认证单位,二维码
$str = $wxID.';'.$wxName.';'.$logo->src.';'.$sp.';'.$auto.';'.$qr_img->src;
//echo $str."<br />";
//saveInfoWx($str);
$savePath = 'data/weixin_'.$type.'.txt';
$link = $html->find('a');
foreach ($link as $key => $value) {
if(checkDetail($value->href)){
}
}
file_put_contents('data/weixin_'.$type.'.txt', $str."\n",FILE_APPEND);
}
function checkUrl($url){
//echo $url."<br/>";
$part = explode('/', $url);
$part1 = explode('.', $url);
if( strpos($url, 'gzh?openid')&& (strlen($url) < 200)){
return true;
}else{
return false;
}
}
function number($str)
{
return preg_replace('/\D/s', '', $str);
}
function saveSql($sql){
file_put_contents('./data/sql_log_wx.txt', $sql.";\n", FILE_APPEND);
}
?>