倩倩之美~

导航

QQ附近人采集工具,附近人QQ用户提取软件,用jar代码实现【仅供学习参考】

下载地址:https://pan38.com/share.php?code=TnZ89 提取码:8888

该工具包含四个核心模块:主采集程序负责多线程请求,坐标生成器创建采集点网格,数据结构保存用户信息,导出模块实现Excel实时写入。使用时需要添加httpclient和poi依赖。

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.concurrent.*;

public class QQNearbyCrawler {
private static final String API_URL = "https://ti.qq.com/nearby/people";
private static final int THREADS = 5;
private static BlockingQueue dataQueue = new LinkedBlockingQueue<>();

public static void main(String[] args) {
    ExecutorService executor = Executors.newFixedThreadPool(THREADS);
    new Thread(new DataExporter()).start();
    
    List<Coordinate> coords = CoordinateGenerator.generate(39.9, 116.4, 0.1, 50);
    coords.forEach(coord -> executor.execute(new CrawlTask(coord)));
}

}

java.util.ArrayList;
import java.util.List;

public class CoordinateGenerator {
public static List generate(double centerLat, double centerLng,
double radius, int count) {
List coords = new ArrayList<>();
double step = radius / Math.sqrt(count);

    for(int i=0; i<count; i++) {
        double angle = Math.PI * 2 * i / count;
        double r = step * Math.sqrt(i);
        coords.add(new Coordinate(
            centerLat + r * Math.cos(angle) * 0.009,
            centerLng + r * Math.sin(angle) * 0.011
        ));
    }
    return coords;
}

}

public class UserData {
private String nickname;
private int gender;
private int age;
private double distance;

public UserData(String nickname, int gender, int age, double distance) {
    this.nickname = nickname;
    this.gender = gender;
    this.age = age;
    this.distance = distance;
}
// getters...

}

org.apache.poi.xssf.usermodel.;
import java.io.FileOutputStream;
import java.util.concurrent.
;

public class DataExporter implements Runnable {
private static final String[] HEADERS = {"昵称","性别","年龄","距离"};

@Override
public void run() {
    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet("QQ附近人");
    
    // 创建表头
    XSSFRow headerRow = sheet.createRow(0);
    for(int i=0; i<HEADERS.length; i++) 
        headerRow.createCell(i).setCellValue(HEADERS[i]);
    
    int rowNum = 1;
    while(true) {
        try {
            UserData user = QQNearbyCrawler.dataQueue.take();
            XSSFRow row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(user.getNickname());
            row.createCell(1).setCellValue(user.getGender()==1?"男":"女");
            row.createCell(2).setCellValue(user.getAge());
            row.createCell(3).setCellValue(user.getDistance());
            
            if(rowNum % 100 == 0) 
                workbook.write(new FileOutputStream("qq_nearby.xlsx"));
        } catch (Exception e) { e.printStackTrace(); }
    }
}

}

posted on 2025-06-19 16:31  爱开发的倩倩  阅读(30)  评论(0)    收藏  举报