当前位置:网站首页>Check whether the filing information of the medical representative is correct
Check whether the filing information of the medical representative is correct
2022-06-11 06:44:00 【chengqiuming】
One background
Medical representative filing platform
home page - Medical representative filing platform

The platform can be queried through the filing number , It can also be combined by the names of the drug marketing license holder and the pharmaceutical representative .
Repeated queries will disable IP, The amount of information queried every day is very small .
It can be done by API Call plus forgery HTTP request IP Address technology to achieve a large number of information inquiries on the registration of pharmaceutical agents . The specific implementation is as follows .
Two Realization
1 HTTP Tool class
package hospital;
import iputils.IPUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
/**
* @className: HttpClientUtils
* @description: This tool uses the latest HttpComponents-Client-4.2.1 , Encapsulates a number of uses HttpClient send out HTTP Requested method
* @date: 2021/2/10
* @author: cakin
*/
public class HttpClientUtils {
private static Log logger = LogFactory.getLog(hospital.HttpClientUtils.class);
private HttpClientUtils() {
}
/**
* send out HTTP_POST request
*
* @param url Request address
* @return Back to JSON character string
* @throws Exception
*/
public static String sendPostByRandomIP(String url) throws Exception {
CloseableHttpClient httpclient = HttpClients.custom().build();
HttpPost post = null;
String resData = null;
CloseableHttpResponse result = null;
try {
post = new HttpPost(url);
String randomIp = IPUtils.getRandomIp();
post.setConfig(RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build());
post.setHeader("Content-Type", "application/json");
post.setHeader("X-Forwarded-For", randomIp);
result = httpclient.execute(post);
if (HttpStatus.SC_OK == result.getStatusLine().getStatusCode()) {
resData = EntityUtils.toString(result.getEntity());
}
} finally {
if (result != null) {
result.close();
}
if (post != null) {
post.releaseConnection();
}
httpclient.close();
}
return resData;
}
}2 IP Tool class
package iputils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import hospital.HttpClientUtils;
import java.util.Random;
public class IPUtils {
/**
* Get a random IP
*/
public static String getRandomIp() {
// Appoint IP Range
int[][] range = {
{607649792, 608174079}, // 36.56.0.0-36.63.255.255
{1038614528, 1039007743}, // 61.232.0.0-61.237.255.255
{1783627776, 1784676351}, // 106.80.0.0-106.95.255.255
{2035023872, 2035154943}, // 121.76.0.0-121.77.255.255
{2078801920, 2079064063}, // 123.232.0.0-123.235.255.255
{-1950089216, -1948778497}, // 139.196.0.0-139.215.255.255
{-1425539072, -1425014785}, // 171.8.0.0-171.15.255.255
{-1236271104, -1235419137}, // 182.80.0.0-182.92.255.255
{-770113536, -768606209}, // 210.25.0.0-210.47.255.255
{-569376768, -564133889}, // 222.16.0.0-222.95.255.255
};
Random random = new Random();
int index = random.nextInt(10);
String ip = num2ip(range[index][0] + random.nextInt(range[index][1] - range[index][0]));
return ip;
}
/*
* Convert decimal to IP Address
*/
public static String num2ip(int ip) {
int[] b = new int[4];
b[0] = (ip >> 24) & 0xff;
b[1] = (ip >> 16) & 0xff;
b[2] = (ip >> 8) & 0xff;
b[3] = ip & 0xff;
// Splicing IP
String x = b[0] + "." + b[1] + "." + b[2] + "." + b[3];
return x;
}
public static void main(String[] args) {
// 1 Check whether the record number is empty , If it is not empty, the check passes
String realName = " beam XX";
String orgName = " China XX Pharmaceutical Co., Ltd ";
// Pull the record number from the website
String url = "https://pharmareps.cpa.org.cn/record/selectcode?representativeName=" + realName + "&orgName=" + orgName;
try {
String res = HttpClientUtils.sendPostByRandomIP(url);
JSONObject jsonObject = JSON.parseObject(res);
Integer checkResult = jsonObject.getInteger("result");
if (checkResult == 0) {
JSONArray entityArray = jsonObject.getJSONArray("entity");
// Record number
JSONObject entityObj = entityArray.getJSONObject(0);
String representativeCode = entityObj.getString("code");
System.out.println(representativeCode);
} else {
}
} catch (Exception e) {
e.printStackTrace();
}
}
}3、 ... and test
2020RU4W6XXX
边栏推荐
- ERROR 1215 (HY000): Cannot add foreign key constraint
- 021-MongoDB数据库从入门到放弃
- MongoDB安装
- 572. subtree of another tree
- Detailed installation instructions for MySQL
- Vulhub 8.1-backdoor vulnerability recurrence
- Wechat applet (authorized login of TP5)
- 必读1:格局越大的人,越懂得说话
- text-overflow失效
- During unity panoramic roaming, AWSD is used to control lens movement, EQ is used to control lens lifting, and the right mouse button is used to control lens rotation.
猜你喜欢

The realization of online Fox game server room configuration battle engagement customization function
![[reading this article is enough!!! Easy to understand] confidence level understanding (95% confidence level and confidence interval)](/img/d6/e61ba5bad2b2847378c4547ce0780d.jpg)
[reading this article is enough!!! Easy to understand] confidence level understanding (95% confidence level and confidence interval)

347. top k high frequency elements

Learn C language well from keywords

Metasploitabile2 target learning

JS two methods to determine whether there are duplicate values in the array
![[]==![]](/img/65/ab724c74b080da319ed5c01c93fdb7.png)
[]==![]

Vulhub 8.1-backdoor vulnerability recurrence

Do you know what the quotation for it talent assignment service is? It is recommended that programmers also understand

Warning: Each child in a list should have a unique “key“ prop.
随机推荐
Differences between FindIndex and indexof
572. subtree of another tree
Ethical discussion on reptile Technology
Detailed explanation of mutual call between C language and Lua
Résoudre le problème de la durée inexacte du fichier audio AAC obtenu par ffmpeg
不同VLAN间的通信
Mongodb installation
On cursor in MySQL
End of 2021 graphics of Shandong University
关于组织开展2022年宁波市重点首版次软件申报工作的通知
100. 相同的树
Handwriting promise [02] - asynchronous logic implementation
[TP5 online export picture generation excel detailed explanation example]
A multi classification model suitable for discrete value classification -- softmax regression
统计某次操作(函数)耗时时长
latex 各种箭头/带文字标号的箭头/可变长箭头
ERROR 1215 (HY000): Cannot add foreign key constraint
Open source cartoon server mango
Learn a trick to use MySQL functions to realize data desensitization
Do you use typescript or anyscript