我正在做一个项目,想在其中集成一个绕过验证码的功能。我一直在为此使用 2captcha 服务,而且它一直很成功,直到我从 Windows 切换到 Linux(Ubu...
我正在开发一个项目,想要集成一个验证码绕过功能。我一直在为此使用 2captcha 服务,在我从 Windows 切换到 Linux(Ubuntu 22.04)之前,它一直很成功。当 我尝试运行此功能时,我不断 “TwoCaptcha”对象没有属性“normal”
def solve_captcha(image_path):
solver = TwoCaptcha(api_key)
try:
result = solver.normal(image_path)
except Exception as e:
logging.error(e)
else:
return result['code']
问题是,我在两个系统上安装了相同的库版本。转换后,我没有更改上述函数代码中的任何内容,官方文档在其示例中包含了该属性。
有人能帮助我理解这个问题吗?
我尝试搜索:库文档( https://pypi.org/project/2captcha-python/ )以及官方服务网页上的示例( https://2captcha.com/api-docs/normal-captcha ),但它们的代码中都包含“正常”属性。
我正在使用来自这个 kaggle 的干净数据集,用于一个学校项目,我必须用 c++ 编写代码来对数据进行排序,并允许我对数据进行统计分析。https://www.kaggle.com/dat...
我正在使用来自这个 kaggle 的干净数据集,用于一个学校项目,我必须用 c++ 编写代码来对数据进行排序并允许我对数据进行统计分析。
https://www.kaggle.com/datasets/elvinrustam/ebay-laptops-and-netbooks-sales/data
我尝试了很多次,但似乎还是搞不清楚如何使用 c++ 忽略数据中的逗号和随机引号。我尝试将每个标题的数据存储到一个向量中,以便之后可以对数据进行操作,但当我打印数据时,我发现数据集中混杂了其他数据,还有随机逗号、括号、长文本等。
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
std::vector<std::string> parseCSVLine(const std::string& line) {
std::vector<std::string> result;
std::string cell;
bool inQuotes = false;
bool inBulletPoint = false; // New flag to track when we're within a bullet point
for (auto it = line.begin(); it != line.end(); ++it) {
const char nextChar = *it;
// Check for bullet points
if (!inQuotes && *it == '•') {
inBulletPoint = true; // We're now inside a bullet point
cell += nextChar; // Add the bullet point character to the cell
continue;
}
// If we're in a bullet point, check for the end of the line or a comma (end of cell)
if (inBulletPoint && (nextChar == ',' || it == line.end() - 1)) {
inBulletPoint = false; // Exiting bullet point mode
if (nextChar != ',') {
cell += nextChar; // Ensure last character is included if not a comma
}
result.push_back(cell);
cell.clear();
continue;
}
else if (inBulletPoint) {
// Simply add the character to the cell without interpreting it
cell += nextChar;
continue;
}
// Handle quotes (outside of bullet points)
if (nextChar == '"') {
if (inQuotes && (it + 1 != line.end()) && (*(it + 1) == '"')) {
cell += nextChar; // Add a single quote to the cell value
++it; // Skip the next quote
}
else {
inQuotes = !inQuotes;
}
}
else if (nextChar == ',' && !inQuotes) {
result.push_back(cell);
cell.clear();
}
else {
cell += nextChar;
}
}
// Only check the last character if the line is not empty
if (!cell.empty() || (!line.empty() && line.back() == ',')) {
result.push_back(cell);
}
return result;
}
int main() {
std::string filePath = "insert file path here";
std::ifstream file(filePath);
if (!file.is_open()) {
std::cerr << "Failed to open file: " << filePath << std::endl;
return 1;
}
std::string line;
std::vector<std::string> headers;
std::vector<std::vector<std::string>> columnData;
if (getline(file, line)) {
headers = parseCSVLine(line);
columnData.resize(headers.size());
}
while (getline(file, line)) {
auto data = parseCSVLine(line);
for (size_t i = 0; i < data.size() && i < columnData.size(); ++i) {
columnData[i].push_back(data[i]);
}
}
file.close();
//// Example output: Printing unique values for each heading for verification
//for (size_t i = 0; i < headers.size(); ++i) {
// std::set<std::string> uniqueValues(columnData[i].begin(), columnData[i].end());
// std::cout << "Heading: " << headers[i] << " - Unique Values: " << uniqueValues.size() << std::endl;
// for (const auto& value : uniqueValues) {
// std::cout << value << std::endl;
// }
// std::cout << std::endl;
//}
// Make sure to define and fill 'columnData' and 'headers' as per your CSV parsing logic before this snippet
// Here, the index is set to 2 since vector indices are 0-based and we want the third column (heading 3)
size_t index = 2;
// Check if the index is within the bounds of the 'columnData' vector
if (index < columnData.size()) {
std::cout << "Values under Heading 3 (" << headers[index] << "):" << std::endl;
// Iterate over the vector at the given index and print each value
for (const auto& value : columnData[index]) {
std::cout << value << std::endl;
}
}
else {
std::cerr << "Index out of range. The columnData does not have a heading 3." << std::endl;
}
return 0;
}