This endpoint will retrieve listing information from a single 'For Sale' property listing page and transform it into usable JSON.
Copy import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) {
try {
String apiKey = "APIKEY";
String jsonInputString = "{"
+ "\"apiKey\": \"" + apiKey + "\", "
+ "\"url\": \"URL\", "
+ "\"country_code\": \"COUNTRY_CODE\", "
+ "\"tld\": \"TLD\", "
+ "\raw\": \"RAW\", "
+ "\"callback\": {"
+ " \"type\": \"webhook\", "
+ " \"url\": \"YYYYY\""
+ "}}";
URL url = new URL("https://async.scraperapi.com/structured/redfin/forsale");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "*/*");
connection.setDoOutput(true);
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
int responseCode = connection.getResponseCode();
StringBuilder response = new StringBuilder();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String readLine;
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
if (responseCode == HttpURLConnection.HTTP_OK) {
System.out.println("Response: " + response.toString());
} else {
throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Copy import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) {
try {
String apiKey = "APIKEY";
String jsonInputString = "{"
+ "\"apiKey\": \"" + apiKey + "\", "
+ "\"urls\": [\"URL1\", \"URL2\"], "
+ "\"country_code\": \"COUNTRY_CODE\", "
+ "\"tld\": \"TLD\", "
+ "\raw\": \"RAW\", "
+ "\"callback\": {"
+ " \"type\": \"webhook\", "
+ " \"url\": \"CALLBACK\""
+ "}}";
URL url = new URL("https://async.scraperapi.com/structured/redfin/forsale");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "*/*");
connection.setDoOutput(true);
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
int responseCode = connection.getResponseCode();
StringBuilder response = new StringBuilder();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String readLine;
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
if (responseCode == HttpURLConnection.HTTP_OK) {
System.out.println("Response: " + response.toString());
} else {
throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Copy {
"id": "aa65d866-b53f-4488-9cbe-2bee29d6f65c",
"status": "running",
"statusUrl": "https://async.scraperapi.com/jobs/aa65d866-b53f-4488-9cbe-2bee29d6f65c",
"url": "https://www.redfin.com/NH/Salem/1-Chestnut-Dr-03079/home/96531263"
}
Copy [
{
"id": "6d282e78-4d1a-46cb-838f-cc59e592774f",
"attempts": 0,
"status": "running",
"statusUrl": "https://async.scraperapi.com/jobs/6d282e78-4d1a-46cb-838f-cc59e592774f",
"url": "https://www.redfin.com/NH/Salem/1-Chestnut-Dr-03079/home/96531263"
},
{
"id": "d59ed100-6213-4097-afe5-6488ec5dda12",
"attempts": 0,
"status": "running",
"statusUrl": "https://async.scraperapi.com/jobs/d59ed100-6213-4097-afe5-6488ec5dda12",
"url": "https://www.redfin.com/MA/Methuen/72-Sheldon-St-01844/home/11773076"
}
]